[aur-dev] [PATCH] Use VARCHAR instead of CHAR where appropriate.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- UPGRADING | 16 ++++++++++++++++ support/schema/aur-schema.sql | 28 ++++++++++++++-------------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/UPGRADING b/UPGRADING index c067af5..661a6c3 100644 --- a/UPGRADING +++ b/UPGRADING @@ -11,6 +11,22 @@ ALTER TABLE Packages ADD OutOfDateTS BIGINT UNSIGNED NULL DEFAULT NULL; UPDATE Packages SET OutOfDateTS = UNIX_TIMESTAMP() WHERE OutOfDate = 1; ALTER TABLE Packages DROP OutOfDate, DROP FSPath, DROP URLPath, DROP LocationID; DROP TABLE PackageLocations, PackageContents; +ALTER TABLE AccountTypes MODIFY AccountType VARCHAR(32) NOT NULL DEFAULT ''; +ALTER TABLE Users MODIFY Username VARCHAR(32) NOT NULL, + MODIFY Email VARCHAR(64) NOT NULL, + MODIFY RealName VARCHAR(64) NOT NULL DEFAULT '', + MODIFY LangPreference VARCHAR(5) NOT NULL DEFAULT 'en', + MODIFY IRCNick VARCHAR(32) NOT NULL DEFAULT ''; +ALTER TABLE PackageCategories MODIFY Category VARCHAR(32) NOT NULL; +ALTER TABLE Packages MODIFY Name VARCHAR(64) NOT NULL, + MODIFY Version VARCHAR(32) NOT NULL DEFAULT '', + MODIFY Description VARCHAR(255) NOT NULL DEFAULT "An Arch Package", + MODIFY URL VARCHAR(255) NOT NULL DEFAULT "http://www.archlinux.org", + MODIFY License VARCHAR(40) NOT NULL DEFAULT ''; +ALTER TABLE PackageSources + MODIFY Source VARCHAR(255) NOT NULL DEFAULT "/dev/null"; +ALTER TABLE TU_VoteInfo + MODIFY User VARCHAR(32) collate latin1_general_ci NOT NULL; ---- 2. You will need to update all packages which are stored in the incoming dir as diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql index cb5ea42..cddf00e 100644 --- a/support/schema/aur-schema.sql +++ b/support/schema/aur-schema.sql @@ -9,7 +9,7 @@ USE AUR; -- CREATE TABLE AccountTypes ( ID TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, - AccountType char(32) NOT NULL DEFAULT '', + AccountType VARCHAR(32) NOT NULL DEFAULT '', PRIMARY KEY (ID) ); INSERT INTO AccountTypes (ID, AccountType) VALUES (1, 'User'); @@ -23,14 +23,14 @@ CREATE TABLE Users ( ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, AccountTypeID TINYINT UNSIGNED NOT NULL DEFAULT 1, Suspended TINYINT UNSIGNED NOT NULL DEFAULT 0, - Username CHAR(32) NOT NULL, - Email CHAR(64) NOT NULL, + Username VARCHAR(32) NOT NULL, + Email VARCHAR(64) NOT NULL, Passwd CHAR(32) NOT NULL, Salt CHAR(32) NOT NULL DEFAULT '', ResetKey CHAR(32) NOT NULL DEFAULT '', - RealName CHAR(64) NOT NULL DEFAULT '', - LangPreference CHAR(5) NOT NULL DEFAULT 'en', - IRCNick CHAR(32) NOT NULL DEFAULT '', + RealName VARCHAR(64) NOT NULL DEFAULT '', + LangPreference VARCHAR(5) NOT NULL DEFAULT 'en', + IRCNick VARCHAR(32) NOT NULL DEFAULT '', LastVoted BIGINT UNSIGNED NOT NULL DEFAULT 0, NewPkgNotify TINYINT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (ID), @@ -66,7 +66,7 @@ CREATE TABLE Sessions ( -- CREATE TABLE PackageCategories ( ID TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, - Category CHAR(32) NOT NULL, + Category VARCHAR(32) NOT NULL, PRIMARY KEY (ID) ); INSERT INTO PackageCategories (Category) VALUES ('none'); @@ -93,13 +93,13 @@ INSERT INTO PackageCategories (Category) VALUES ('xfce'); -- CREATE TABLE Packages ( ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - Name CHAR(64) NOT NULL, - Version CHAR(32) NOT NULL DEFAULT '', + Name VARCHAR(64) NOT NULL, + Version VARCHAR(32) NOT NULL DEFAULT '', CategoryID TINYINT UNSIGNED NOT NULL DEFAULT 1, - Description CHAR(255) NOT NULL DEFAULT "An Arch Package", - URL CHAR(255) NOT NULL DEFAULT "http://www.archlinux.org", + Description VARCHAR(255) NOT NULL DEFAULT "An Arch Package", + URL VARCHAR(255) NOT NULL DEFAULT "http://www.archlinux.org", DummyPkg TINYINT UNSIGNED NOT NULL DEFAULT 0, -- 1=>dummy - License CHAR(40) NOT NULL DEFAULT '', + License VARCHAR(40) NOT NULL DEFAULT '', NumVotes INTEGER UNSIGNED NOT NULL DEFAULT 0, OutOfDateTS BIGINT UNSIGNED NULL DEFAULT NULL, SubmittedTS BIGINT UNSIGNED NOT NULL, @@ -134,7 +134,7 @@ CREATE TABLE PackageDepends ( -- CREATE TABLE PackageSources ( PackageID INTEGER UNSIGNED NOT NULL, - Source CHAR(255) NOT NULL DEFAULT "/dev/null", + Source VARCHAR(255) NOT NULL DEFAULT "/dev/null", INDEX (PackageID) ); @@ -183,7 +183,7 @@ CREATE UNIQUE INDEX NotifyUserIDPkgID ON CommentNotify (UserID, PkgID); CREATE TABLE IF NOT EXISTS TU_VoteInfo ( ID int(10) unsigned NOT NULL auto_increment, Agenda text collate latin1_general_ci NOT NULL, - User char(32) collate latin1_general_ci NOT NULL, + User VARCHAR(32) collate latin1_general_ci NOT NULL, Submitted bigint(20) unsigned NOT NULL, End bigint(20) unsigned NOT NULL, SubmitterID int(10) unsigned NOT NULL, -- 1.7.4
On Tue 08 Feb 2011 10:40 +0100, Lukas Fleischer wrote:
- LangPreference CHAR(5) NOT NULL DEFAULT 'en',
I think LangPreference could probably remain at CHAR, but I am no i18n or DB whiz.
On Tue, Feb 8, 2011 at 8:31 PM, Loui Chang <louipc.ist@gmail.com> wrote:
On Tue 08 Feb 2011 10:40 +0100, Lukas Fleischer wrote:
- LangPreference CHAR(5) NOT NULL DEFAULT 'en',
I think LangPreference could probably remain at CHAR, but I am no i18n or DB whiz.
If it isn't something that must be X characters, it makes more sense to use varchar. In this case, we can see that the default is only 2 chars, so varchar seems appropriate to me. -Dan
On Tue, Feb 08, 2011 at 09:13:07PM -0600, Dan McGee wrote:
On Tue, Feb 8, 2011 at 8:31 PM, Loui Chang <louipc.ist@gmail.com> wrote:
On Tue 08 Feb 2011 10:40 +0100, Lukas Fleischer wrote:
- LangPreference CHAR(5) NOT NULL DEFAULT 'en',
I think LangPreference could probably remain at CHAR, but I am no i18n or DB whiz.
If it isn't something that must be X characters, it makes more sense to use varchar. In this case, we can see that the default is only 2 chars, so varchar seems appropriate to me.
Ack. Applied this to my working tree.
participants (3)
-
Dan McGee
-
Loui Chang
-
Lukas Fleischer