Made all page_id and namespace columns consistent
authorDan
Mon, 16 Feb 2009 16:04:54 -0500
changeset 831 45e887f23282
parent 830 79fb483807f6
child 832 7152ca0a0ce9
Made all page_id and namespace columns consistent
install/schemas/mysql_stage2.sql
install/schemas/postgresql_stage2.sql
install/schemas/upgrade/1.1.5-1.1.6-mysql.sql
install/schemas/upgrade/1.1.5-1.1.6-postgresql.sql
--- a/install/schemas/mysql_stage2.sql	Mon Feb 16 16:04:31 2009 -0500
+++ b/install/schemas/mysql_stage2.sql	Mon Feb 16 16:04:54 2009 -0500
@@ -11,15 +11,15 @@
 -- mysql_stage2.sql - MySQL installation schema, main payload
 
 CREATE TABLE {{TABLE_PREFIX}}categories(
-  page_id varchar(64),
-  namespace varchar(64),
+  page_id varchar(512),
+  namespace varchar(16),
   category_id varchar(64)
 ) CHARACTER SET `utf8` COLLATE `utf8_bin`;
 
 CREATE TABLE {{TABLE_PREFIX}}comments(
   comment_id int(12) NOT NULL auto_increment,
-  page_id text,
-  namespace text,
+  page_id varchar(512),
+  namespace varchar(16),
   subject text,
   comment_data text,
   name text,
@@ -36,19 +36,20 @@
   action varchar(16),
   time_id int(12) NOT NULL DEFAULT '0',
   date_string varchar(63),
-  page_id text,
-  namespace text,
+  page_id varchar(512),
+  namespace varchar(16),
   page_text text,
   char_tag varchar(40),
   author varchar(63),
   edit_summary text,
   minor_edit tinyint(1),
+  page_format varchar(16) NOT NULL DEFAULT 'wikitext',
   is_draft tinyint(1) NOT NULL DEFAULT 0,
   PRIMARY KEY ( log_id )
 ) CHARACTER SET `utf8` COLLATE `utf8_bin`;
 
 CREATE TABLE {{TABLE_PREFIX}}page_text(
-  page_id varchar(255),
+  page_id varchar(512),
   namespace varchar(16) NOT NULL DEFAULT 'Article',
   page_text text,
   char_tag varchar(63),
@@ -63,6 +64,7 @@
   special tinyint(1) default '0',
   visible tinyint(1) default '1',
   comments_on tinyint(1) default '1',
+  page_format varchar(16) NOT NULL DEFAULT 'wikitext',
   protected tinyint(1) NOT NULL DEFAULT 0,
   wiki_mode tinyint(1) NOT NULL DEFAULT 2,
   delvotes int(10) NOT NULL DEFAULT 0,
@@ -148,7 +150,7 @@
 CREATE TABLE {{TABLE_PREFIX}}files(
   file_id int(12) NOT NULL auto_increment,
   time_id int(12) NOT NULL,
-  page_id varchar(63) NOT NULL,
+  page_id varchar(512) NOT NULL,
   filename varchar(127) default NULL,
   size bigint(15) NOT NULL,
   mimetype varchar(63) default NULL,
@@ -192,8 +194,8 @@
   hit_id bigint(20) NOT NULL auto_increment,
   username varchar(63) NOT NULL,
   time int(12) NOT NULL DEFAULT 0,
-  page_id varchar(63),
-  namespace varchar(63),
+  page_id varchar(512),
+  namespace varchar(16),
   PRIMARY KEY ( hit_id ) 
 ) CHARACTER SET `utf8` COLLATE `utf8_bin`;
 
@@ -226,8 +228,8 @@
   rule_id int(12) UNSIGNED NOT NULL auto_increment,
   target_type tinyint(1) UNSIGNED NOT NULL,
   target_id int(12) UNSIGNED NOT NULL,
-  page_id varchar(255),
-  namespace varchar(24),
+  page_id varchar(512),
+  namespace varchar(16),
   rules text,
   PRIMARY KEY ( rule_id ) 
 ) CHARACTER SET `utf8` COLLATE `utf8_bin`;
@@ -247,8 +249,8 @@
 CREATE TABLE {{TABLE_PREFIX}}page_group_members(
   pg_member_id int(12) NOT NULL auto_increment,
   pg_id mediumint(8) NOT NULL,
-  page_id varchar(63) NOT NULL,
-  namespace varchar(63) NOT NULL DEFAULT 'Article',
+  page_id varchar(512) NOT NULL,
+  namespace varchar(16) NOT NULL DEFAULT 'Article',
   PRIMARY KEY ( pg_member_id )
 ) CHARACTER SET `utf8` COLLATE `utf8_bin`;
 
@@ -257,8 +259,8 @@
 CREATE TABLE {{TABLE_PREFIX}}tags(
   tag_id int(12) NOT NULL auto_increment,
   tag_name varchar(63) NOT NULL DEFAULT 'bla',
-  page_id varchar(255) NOT NULL,
-  namespace varchar(255) NOT NULL,
+  page_id varchar(512) NOT NULL,
+  namespace varchar(16) NOT NULL,
   user_id mediumint(8) NOT NULL DEFAULT 1,
   PRIMARY KEY ( tag_id )
 ) CHARACTER SET `utf8` COLLATE `utf8_bin`;
@@ -337,29 +339,24 @@
   PRIMARY KEY ( plugin_id )
 ) ENGINE `MyISAM` CHARACTER SET `utf8` COLLATE `utf8_bin`;
 
+-- Added in 1.1.6: Indices for several tables
+-- The size of 317 is a trial-and-error-produced value based on MySQL's index column size limit
+-- of 1000 bytes. It's low like that because of the UTF-8 character set being used.
+ALTER TABLE {{TABLE_PREFIX}}logs ADD INDEX {{TABLE_PREFIX}}logs_page_idx (page_id(317), namespace);
+ALTER TABLE {{TABLE_PREFIX}}logs ADD INDEX {{TABLE_PREFIX}}logs_time_idx (time_id);
+ALTER TABLE {{TABLE_PREFIX}}comments ADD INDEX {{TABLE_PREFIX}}comments_page_idx (page_id(317), namespace);
+
+-- The default config. Kind of important.
+-- P.S. the allowed_mime_types value is a compressed bitfield. Source for the (rather simple) algo is in functions.php.
+
 INSERT INTO {{TABLE_PREFIX}}config(config_name, config_value) VALUES
   ('site_name', '{{SITE_NAME}}'),
-  ('main_page', 'Main_Page'),
   ('site_desc', '{{SITE_DESC}}'),
   ('wiki_mode', '{{WIKI_MODE}}'),
-  ('wiki_edit_notice', '0'),
-  ('sflogo_enabled', '0'),
-  ('sflogo_groupid', ''),
-  ('sflogo_type', '1'),
-  ('w3c_vh32', '0'),
-  ('w3c_vh40', '0'),
-  ('w3c_vh401', '0'),
-  ('w3c_vxhtml10', '0'),
-  ('w3c_vxhtml11', '0'),
-  ('w3c_vcss', '0'),
-  ('approve_comments', '0'),
-  ('enable_comments', '1'),
   ('copyright_notice', '{{COPYRIGHT}}'),
-  ('wiki_edit_notice_text', '== Why can I edit this page? ==\n\nEveryone can edit almost any page in this website. This concept is called a wiki. It gives everyone the opportunity to make a change for the best. While some spam and vandalism may occur, it is believed that most contributions will be legitimate and helpful.\n\nFor security purposes, a history of all page edits is kept, and administrators are able to restore vandalized or spammed pages with just a few clicks.'),
   ('cache_thumbs', '{{ENABLE_CACHE}}'),
-  ('max_file_size', '256000'),('enano_version', '{{VERSION}}'),( 'allowed_mime_types', 'cbf:len=185;crc=55fb6f14;data=0[1],1[4],0[3],1[1],0[22],1[1],0[16],1[3],0[16],1[1],0[1],1[2],0[6],1[1],0[1],1[1],0[4],1[2],0[3],1[1],0[48],1[2],0[2],1[1],0[4],1[1],0[37]|end' ),
   ('contact_email', '{{ADMIN_EMAIL}}'),
-  ('powered_btn', '1');
+  ('allowed_mime_types', 'cbf2:7414a6b80184038102810b810781098106830a810282018101820683018102840182038104821a850682028104810a82018116');
 
 INSERT INTO {{TABLE_PREFIX}}page_text(page_id, namespace, page_text, char_tag) VALUES
   ('Main_Page', 'Article', '{{MAIN_PAGE_CONTENT}}', '');
@@ -387,9 +384,10 @@
   (3, 'user_rank_admin', 'font-weight: bold; color: #AA0000;'),
   (4, 'user_rank_guest', '');
 
-INSERT INTO {{TABLE_PREFIX}}groups(group_id,group_name,group_type,system_group) VALUES(1, 'Everyone', 3, 1),
-  (2,'Administrators',3,1),
-  (3,'Moderators',3,1);
+INSERT INTO {{TABLE_PREFIX}}groups(group_id,group_name,group_type,system_group) VALUES
+  (1, 'Everyone', 3, 1),
+  (2, 'Administrators', 3, 1),
+  (3, 'Moderators', 3, 1);
 
 INSERT INTO {{TABLE_PREFIX}}group_members(group_id,user_id,is_mod) VALUES(2, 2, 1);
 
--- a/install/schemas/postgresql_stage2.sql	Mon Feb 16 16:04:31 2009 -0500
+++ b/install/schemas/postgresql_stage2.sql	Mon Feb 16 16:04:54 2009 -0500
@@ -11,15 +11,15 @@
 -- postgresql_stage2.sql - PostgreSQL installation schema, main payload
 
 CREATE TABLE {{TABLE_PREFIX}}categories(
-  page_id varchar(64),
-  namespace varchar(64),
+  page_id varchar(512),
+  namespace varchar(16),
   category_id varchar(64)
 );
 
 CREATE TABLE {{TABLE_PREFIX}}comments(
   comment_id SERIAL,
-  page_id text,
-  namespace text,
+  page_id varchar(512),
+  namespace varchar(16),
   subject text,
   comment_data text,
   name text,
@@ -36,8 +36,8 @@
   action varchar(16),
   time_id int NOT NULL DEFAULT '0',
   date_string varchar(63),
-  page_id text,
-  namespace text,
+  page_id varchar(512),
+  namespace varchar(16),
   page_text text,
   char_tag varchar(40),
   author varchar(63),
@@ -48,7 +48,7 @@
 );
 
 CREATE TABLE {{TABLE_PREFIX}}page_text(
-  page_id varchar(255),
+  page_id varchar(512),
   namespace varchar(16) NOT NULL DEFAULT 'Article',
   page_text text,
   char_tag varchar(63)
@@ -62,6 +62,7 @@
   special smallint DEFAULT '0',
   visible smallint DEFAULT '1',
   comments_on smallint DEFAULT '1',
+  page_format varchar(16) NOT NULL DEFAULT 'wikitext',
   protected smallint NOT NULL DEFAULT 0,
   wiki_mode smallint NOT NULL DEFAULT 2,
   delvotes int NOT NULL DEFAULT 0,
@@ -149,7 +150,7 @@
 CREATE TABLE {{TABLE_PREFIX}}files(
   file_id SERIAL,
   time_id int NOT NULL,
-  page_id varchar(63) NOT NULL,
+  page_id varchar(512) NOT NULL,
   filename varchar(127) DEFAULT NULL,
   size bigint NOT NULL,
   mimetype varchar(63) DEFAULT NULL,
@@ -193,8 +194,8 @@
   hit_id SERIAL,
   username varchar(63) NOT NULL,
   time int NOT NULL DEFAULT 0,
-  page_id varchar(63),
-  namespace varchar(63),
+  page_id varchar(512),
+  namespace varchar(16),
   PRIMARY KEY ( hit_id ) 
 );
 
@@ -227,8 +228,8 @@
   rule_id SERIAL,
   target_type smallint NOT NULL,
   target_id int NOT NULL,
-  page_id varchar(255),
-  namespace varchar(24),
+  page_id varchar(512),
+  namespace varchar(16),
   rules text,
   PRIMARY KEY ( rule_id ) 
 );
@@ -248,8 +249,8 @@
 CREATE TABLE {{TABLE_PREFIX}}page_group_members(
   pg_member_id SERIAL,
   pg_id int NOT NULL,
-  page_id varchar(63) NOT NULL,
-  namespace varchar(63) NOT NULL DEFAULT 'Article',
+  page_id varchar(512) NOT NULL,
+  namespace varchar(16) NOT NULL DEFAULT 'Article',
   PRIMARY KEY ( pg_member_id )
 );
 
@@ -258,8 +259,8 @@
 CREATE TABLE {{TABLE_PREFIX}}tags(
   tag_id SERIAL,
   tag_name varchar(63) NOT NULL DEFAULT 'bla',
-  page_id varchar(255) NOT NULL,
-  namespace varchar(255) NOT NULL,
+  page_id varchar(512) NOT NULL,
+  namespace varchar(16) NOT NULL,
   user_id int NOT NULL DEFAULT 1,
   PRIMARY KEY ( tag_id )
 );
--- a/install/schemas/upgrade/1.1.5-1.1.6-mysql.sql	Mon Feb 16 16:04:31 2009 -0500
+++ b/install/schemas/upgrade/1.1.5-1.1.6-mysql.sql	Mon Feb 16 16:04:54 2009 -0500
@@ -1,2 +1,27 @@
-ALTER TABLE users ADD COLUMN password_salt varchar(40) NOT NULL DEFAULT '';
+ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN password_salt varchar(40) NOT NULL DEFAULT '';
+ALTER TABLE {{TABLE_PREFIX}}pages ADD COLUMN page_format varchar(16) NOT NULL DEFAULT 'wikitext';
+ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN page_format varchar(16) NOT NULL DEFAULT 'wikitext';
+
+-- Make page_id and namespace column sizes consistent (former bug)
+
+ALTER TABLE {{TABLE_PREFIX}}comments MODIFY COLUMN page_id varchar(512) NOT NULL,
+  MODIFY COLUMN namespace varchar(16) NOT NULL;
+
+ALTER TABLE {{TABLE_PREFIX}}logs MODIFY COLUMN page_id varchar(512) NOT NULL,
+  MODIFY COLUMN namespace varchar(16) NOT NULL;
+
+ALTER TABLE {{TABLE_PREFIX}}page_text MODIFY COLUMN page_id varchar(512) NOT NULL;
 
+ALTER TABLE {{TABLE_PREFIX}}pages MODIFY COLUMN urlname varchar(512) NOT NULL;
+
+ALTER TABLE {{TABLE_PREFIX}}hits MODIFY COLUMN page_id varchar(512) NOT NULL,
+  MODIFY COLUMN namespace varchar(16) NOT NULL;
+
+ALTER TABLE {{TABLE_PREFIX}}acl MODIFY COLUMN page_id varchar(512),
+  MODIFY COLUMN namespace varchar(16);
+
+ALTER TABLE {{TABLE_PREFIX}}page_group_members MODIFY COLUMN page_id varchar(512) NOT NULL,
+  MODIFY COLUMN namespace varchar(16) NOT NULL;
+
+ALTER TABLE {{TABLE_PREFIX}}tags MODIFY COLUMN page_id varchar(512) NOT NULL,
+  MODIFY COLUMN namespace varchar(16) NOT NULL;
--- a/install/schemas/upgrade/1.1.5-1.1.6-postgresql.sql	Mon Feb 16 16:04:31 2009 -0500
+++ b/install/schemas/upgrade/1.1.5-1.1.6-postgresql.sql	Mon Feb 16 16:04:54 2009 -0500
@@ -1,2 +1,86 @@
-ALTER TABLE users ADD COLUMN password_salt varchar(40) NOT NULL DEFAULT '';
+ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN password_salt varchar(40) NOT NULL DEFAULT '';
+ALTER TABLE {{TABLE_PREFIX}}pages ADD COLUMN page_format varchar(16) NOT NULL DEFAULT 'wikitext';
+ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN page_format varchar(16) NOT NULL DEFAULT 'wikitext';
+
+--
+-- Make page_id and namespace column sizes consistent (former bug)
+-- Yes, this is a PITA in PostgreSQL.
+--
+
+-- comments
+ALTER TABLE {{TABLE_PREFIX}}comments ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT '';
+UPDATE {{TABLE_PREFIX}}comments SET page_id_new = page_id;
+ALTER TABLE {{TABLE_PREFIX}}comments DROP page_id;
+ALTER TABLE {{TABLE_PREFIX}}comments RENAME page_id_new TO page_id;
+
+ALTER TABLE {{TABLE_PREFIX}}comments ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT '';
+UPDATE {{TABLE_PREFIX}}comments SET namespace_new = namespace;
+ALTER TABLE {{TABLE_PREFIX}}comments DROP namespace;
+ALTER TABLE {{TABLE_PREFIX}}comments RENAME namespace_new TO namespace;
+
+-- logs
+ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT '';
+UPDATE {{TABLE_PREFIX}}logs SET page_id_new = page_id;
+ALTER TABLE {{TABLE_PREFIX}}logs DROP page_id;
+ALTER TABLE {{TABLE_PREFIX}}logs RENAME page_id_new TO page_id;
+
+ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT '';
+UPDATE {{TABLE_PREFIX}}logs SET namespace_new = namespace;
+ALTER TABLE {{TABLE_PREFIX}}logs DROP namespace;
+ALTER TABLE {{TABLE_PREFIX}}logs RENAME namespace_new TO namespace;
+
+-- page_text
+ALTER TABLE {{TABLE_PREFIX}}page_text ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT '';
+UPDATE {{TABLE_PREFIX}}page_text SET page_id_new = page_id;
+ALTER TABLE {{TABLE_PREFIX}}page_text DROP page_id;
+ALTER TABLE {{TABLE_PREFIX}}page_text RENAME page_id_new TO page_id;
+
+-- pages
+ALTER TABLE {{TABLE_PREFIX}}pages ADD COLUMN urlname_new varchar(512) NOT NULL DEFAULT '';
+UPDATE {{TABLE_PREFIX}}pages SET urlname_new = urlname;
+ALTER TABLE {{TABLE_PREFIX}}pages DROP urlname;
+ALTER TABLE {{TABLE_PREFIX}}pages RENAME urlname_new TO urlname;
 
+-- hits
+ALTER TABLE {{TABLE_PREFIX}}hits ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT '';
+UPDATE {{TABLE_PREFIX}}hits SET page_id_new = page_id;
+ALTER TABLE {{TABLE_PREFIX}}hits DROP page_id;
+ALTER TABLE {{TABLE_PREFIX}}hits RENAME page_id_new TO page_id;
+
+ALTER TABLE {{TABLE_PREFIX}}hits ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT '';
+UPDATE {{TABLE_PREFIX}}hits SET namespace_new = namespace;
+ALTER TABLE {{TABLE_PREFIX}}hits DROP namespace;
+ALTER TABLE {{TABLE_PREFIX}}hits RENAME namespace_new TO namespace;
+
+-- acl
+ALTER TABLE {{TABLE_PREFIX}}acl ADD COLUMN page_id_new varchar(512) DEFAULT NULL;
+UPDATE {{TABLE_PREFIX}}acl SET page_id_new = page_id;
+ALTER TABLE {{TABLE_PREFIX}}acl DROP page_id;
+ALTER TABLE {{TABLE_PREFIX}}acl RENAME page_id_new TO page_id;
+
+ALTER TABLE {{TABLE_PREFIX}}acl ADD COLUMN namespace_new varchar(16) DEFAULT NULL;
+UPDATE {{TABLE_PREFIX}}acl SET namespace_new = namespace;
+ALTER TABLE {{TABLE_PREFIX}}acl DROP namespace;
+ALTER TABLE {{TABLE_PREFIX}}acl RENAME namespace_new TO namespace;
+
+-- page_group_members
+ALTER TABLE {{TABLE_PREFIX}}page_group_members ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT '';
+UPDATE {{TABLE_PREFIX}}page_group_members SET page_id_new = page_id;
+ALTER TABLE {{TABLE_PREFIX}}page_group_members DROP page_id;
+ALTER TABLE {{TABLE_PREFIX}}page_group_members RENAME page_id_new TO page_id;
+
+ALTER TABLE {{TABLE_PREFIX}}page_group_members ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT '';
+UPDATE {{TABLE_PREFIX}}page_group_members SET namespace_new = namespace;
+ALTER TABLE {{TABLE_PREFIX}}page_group_members DROP namespace;
+ALTER TABLE {{TABLE_PREFIX}}page_group_members RENAME namespace_new TO namespace;
+
+-- tags
+ALTER TABLE {{TABLE_PREFIX}}tags ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT '';
+UPDATE {{TABLE_PREFIX}}tags SET page_id_new = page_id;
+ALTER TABLE {{TABLE_PREFIX}}tags DROP page_id;
+ALTER TABLE {{TABLE_PREFIX}}tags RENAME page_id_new TO page_id;
+
+ALTER TABLE {{TABLE_PREFIX}}tags ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT '';
+UPDATE {{TABLE_PREFIX}}tags SET namespace_new = namespace;
+ALTER TABLE {{TABLE_PREFIX}}tags DROP namespace;
+ALTER TABLE {{TABLE_PREFIX}}tags RENAME namespace_new TO namespace;