r98657 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98656‎ | r98657 | r98658 >
Date:06:10, 2 October 2011
Author:maxsem
Status:ok (Comments)
Tags:
Comment:
Revert r98355 and r98357; drop the field instead.
Modified paths:
  • /trunk/phase3/includes/installer/SqliteUpdater.php (modified) (history)
  • /trunk/phase3/maintenance/sqlite/archives/initial-indexes.sql (modified) (history)
  • /trunk/phase3/maintenance/sqlite/archives/patch-drop-user_options.sql (added) (history)
  • /trunk/phase3/tests/phpunit/includes/db/DatabaseSqliteTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/db/sqlite/tables-1.13.sql (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/db/sqlite/tables-1.15.sql (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/db/sqlite/tables-1.16.sql (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/db/sqlite/tables-1.17.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/sqlite/archives/initial-indexes.sql
@@ -41,6 +41,7 @@
4242 user_newpassword tinyblob NOT NULL,
4343 user_newpass_time binary(14),
4444 user_email tinytext NOT NULL,
 45+ user_options blob NOT NULL,
4546 user_touched binary(14) NOT NULL default '',
4647 user_token binary(32) NOT NULL default '',
4748 user_email_authenticated binary(14),
Index: trunk/phase3/maintenance/sqlite/archives/patch-drop-user_options.sql
@@ -0,0 +1,31 @@
 2+-- Remove user_options field from user table
 3+
 4+CREATE TABLE /*_*/user_tmp (
 5+ user_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
 6+ user_name varchar(255) binary NOT NULL default '',
 7+ user_real_name varchar(255) binary NOT NULL default '',
 8+ user_password tinyblob NOT NULL,
 9+ user_newpassword tinyblob NOT NULL,
 10+ user_newpass_time binary(14),
 11+ user_email tinytext NOT NULL,
 12+ user_touched binary(14) NOT NULL default '',
 13+ user_token binary(32) NOT NULL default '',
 14+ user_email_authenticated binary(14),
 15+ user_email_token binary(32),
 16+ user_email_token_expires binary(14),
 17+ user_registration binary(14),
 18+ user_editcount int
 19+) /*$wgDBTableOptions*/;
 20+
 21+INSERT INTO /*_*/user_tmp
 22+ SELECT user_id, user_name, user_real_name, user_password, user_newpassword, user_newpass_time, user_email, user_touched,
 23+ user_token, user_email_authenticated, user_email_token, user_email_token_expires, user_registration, user_editcount
 24+ FROM /*_*/user;
 25+
 26+DROP TABLE /*_*/user;
 27+
 28+ALTER TABLE /*_*/user_tmp RENAME TO /*_*/user;
 29+
 30+CREATE UNIQUE INDEX /*i*/user_name ON /*_*/user (user_name);
 31+CREATE INDEX /*i*/user_email_token ON /*_*/user (user_email_token);
 32+CREATE INDEX /*i*/user_email ON /*_*/user (user_email(50));
Index: trunk/phase3/tests/phpunit/includes/db/sqlite/tables-1.13.sql
@@ -8,6 +8,7 @@
99 user_newpassword tinyblob ,
1010 user_newpass_time BLOB,
1111 user_email tinytext ,
 12+ user_options blob ,
1213 user_touched BLOB default '',
1314 user_token BLOB default '',
1415 user_email_authenticated BLOB,
Index: trunk/phase3/tests/phpunit/includes/db/sqlite/tables-1.15.sql
@@ -10,6 +10,7 @@
1111 user_newpassword tinyblob NOT NULL,
1212 user_newpass_time binary(14),
1313 user_email tinytext NOT NULL,
 14+ user_options blob NOT NULL,
1415 user_touched binary(14) NOT NULL default '',
1516 user_token binary(32) NOT NULL default '',
1617 user_email_authenticated binary(14),
Index: trunk/phase3/tests/phpunit/includes/db/sqlite/tables-1.16.sql
@@ -10,6 +10,7 @@
1111 user_newpassword tinyblob NOT NULL,
1212 user_newpass_time binary(14),
1313 user_email tinytext NOT NULL,
 14+ user_options blob NOT NULL,
1415 user_touched binary(14) NOT NULL default '',
1516 user_token binary(32) NOT NULL default '',
1617 user_email_authenticated binary(14),
Index: trunk/phase3/tests/phpunit/includes/db/sqlite/tables-1.17.sql
@@ -10,6 +10,7 @@
1111 user_newpassword tinyblob NOT NULL,
1212 user_newpass_time binary(14),
1313 user_email tinytext NOT NULL,
 14+ user_options blob NOT NULL,
1415 user_touched binary(14) NOT NULL default '',
1516 user_token binary(32) NOT NULL default '',
1617 user_email_authenticated binary(14),
Index: trunk/phase3/tests/phpunit/includes/db/DatabaseSqliteTest.php
@@ -196,7 +196,6 @@
197197 // Mismatches for these columns we can safely ignore
198198 $ignoredColumns = array(
199199 'user_newtalk.user_last_timestamp', // r84185
200 - 'user.user_options',
201200 );
202201
203202 $currentDB = new DatabaseSqliteStandalone( ':memory:' );
Index: trunk/phase3/includes/installer/SqliteUpdater.php
@@ -64,6 +64,7 @@
6565 array( 'addTable', 'config', 'patch-config.sql' ),
6666 array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql'),
6767 array( 'doMigrateUserOptions' ),
 68+ array( 'dropField', 'user', 'user_options', 'patch-drop-user_options.sql' ),
6869 );
6970 }
7071

Follow-up revisions

RevisionCommit summaryAuthorDate
r98856svn:eol-style nativeialex14:11, 4 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98355Followup r98339...reedy19:28, 28 September 2011
r98357Followup r98339, r98355...reedy19:38, 28 September 2011

Comments

#Comment by Krinkle (talk | contribs)   21:17, 5 October 2011

Don't forget the svn props (Subversion/auto-props)

#Comment by Tim Starling (talk | contribs)   05:26, 25 November 2011

If new fields are added to the user table, this patch would have to be maintained. Is there really no way to do an ALTER TABLE is SQLite that drops a field? If not, maybe we should duplicate the table structure in PHP code rather than using a patch file.

#Comment by MaxSem (talk | contribs)   05:38, 25 November 2011

The updates are applied in a well-defined order, so this update will be run before any later updates that add columns to that table, and I have tests that verify this.

#Comment by Catrope (talk | contribs)   11:42, 25 November 2011

No, ALTER TABLE in SQLite is very limited. See http://www.sqlite.org/faq.html#q11 and http://www.sqlite.org/lang_altertable.html

Status & tagging log