X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=blobdiff_plain;f=includes%2Finstaller%2FPostgresUpdater.php;h=bd1679a9cde1f64e5e09ed4e9518c978bf4292c4;hb=dd942172f81013f0866370b2acb1eee829de19d3;hp=8d1240495fd54af8ada2f6e413c621b5849896e8;hpb=5bf7087cefdb77daaefd7a488ae68cae60b3e406;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index 8d1240495f..bd1679a9cd 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -294,7 +294,7 @@ class PostgresUpdater extends DatabaseUpdater { [ 'log_timestamp', 'timestamptz_ops', 'btree', 0 ], ], 'CREATE INDEX "logging_times" ON "logging" USING "btree" ("log_timestamp")' ], - [ 'dropIndex', 'oldimage', 'oi_name' ], + [ 'dropPgIndex', 'oldimage', 'oi_name' ], [ 'checkIndex', 'oi_name_archive_name', [ [ 'oi_name', 'text_ops', 'btree', 0 ], [ 'oi_archive_name', 'text_ops', 'btree', 0 ], @@ -353,7 +353,7 @@ class PostgresUpdater extends DatabaseUpdater { [ 'checkOiNameConstraint' ], [ 'checkPageDeletedTrigger' ], [ 'checkRevUserFkey' ], - [ 'dropIndex', 'ipblocks', 'ipb_address' ], + [ 'dropPgIndex', 'ipblocks', 'ipb_address' ], [ 'checkIndex', 'ipb_address_unique', [ [ 'ipb_address', 'text_ops', 'btree', 0 ], [ 'ipb_user', 'int4_ops', 'btree', 0 ], @@ -481,16 +481,63 @@ class PostgresUpdater extends DatabaseUpdater { [ 'changeNullableField', 'protected_titles', 'pt_reason', 'NOT NULL', true ], [ 'addPgField', 'protected_titles', 'pt_reason_id', 'INTEGER NOT NULL DEFAULT 0' ], [ 'addTable', 'comment', 'patch-comment-table.sql' ], + + // This field was added in 1.31, but is put here so it can be used by 'migrateComments' + [ 'addPgField', 'image', 'img_description_id', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'migrateComments' ], [ 'addIndex', 'site_stats', 'site_stats_pkey', 'patch-site_stats-pk.sql' ], [ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ], // 1.31 [ 'addTable', 'slots', 'patch-slots-table.sql' ], + [ 'dropPgIndex', 'slots', 'slot_role_inherited' ], + [ 'dropPgField', 'slots', 'slot_inherited' ], + [ 'addPgField', 'slots', 'slot_origin', 'INTEGER NOT NULL' ], + [ + 'addPgIndex', + 'slots', + 'slot_revision_origin_role', + '( slot_revision_id, slot_origin, slot_role_id )', + ], [ 'addTable', 'content', 'patch-content-table.sql' ], [ 'addTable', 'content_models', 'patch-content_models-table.sql' ], [ 'addTable', 'slot_roles', 'patch-slot_roles-table.sql' ], [ 'migrateArchiveText' ], + [ 'addTable', 'actor', 'patch-actor-table.sql' ], + [ 'setDefault', 'revision', 'rev_user', 0 ], + [ 'setDefault', 'revision', 'rev_user_text', '' ], + [ 'setDefault', 'archive', 'ar_user', 0 ], + [ 'changeNullableField', 'archive', 'ar_user', 'NOT NULL', true ], + [ 'setDefault', 'archive', 'ar_user_text', '' ], + [ 'addPgField', 'archive', 'ar_actor', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'addPgIndex', 'archive', 'archive_actor', '( ar_actor )' ], + [ 'setDefault', 'ipblocks', 'ipb_by', 0 ], + [ 'addPgField', 'ipblocks', 'ipb_by_actor', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'setDefault', 'image', 'img_user', 0 ], + [ 'changeNullableField', 'image', 'img_user', 'NOT NULL', true ], + [ 'setDefault', 'image', 'img_user_text', '' ], + [ 'addPgField', 'image', 'img_actor', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'setDefault', 'oldimage', 'oi_user', 0 ], + [ 'changeNullableField', 'oldimage', 'oi_user', 'NOT NULL', true ], + [ 'setDefault', 'oldimage', 'oi_user_text', '' ], + [ 'addPgField', 'oldimage', 'oi_actor', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'setDefault', 'filearchive', 'fa_user', 0 ], + [ 'changeNullableField', 'filearchive', 'fa_user', 'NOT NULL', true ], + [ 'setDefault', 'filearchive', 'fa_user_text', '' ], + [ 'addPgField', 'filearchive', 'fa_actor', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'setDefault', 'recentchanges', 'rc_user', 0 ], + [ 'changeNullableField', 'recentchanges', 'rc_user', 'NOT NULL', true ], + [ 'setDefault', 'recentchanges', 'rc_user_text', '' ], + [ 'addPgField', 'recentchanges', 'rc_actor', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'setDefault', 'logging', 'log_user', 0 ], + [ 'changeNullableField', 'logging', 'log_user', 'NOT NULL', true ], + [ 'addPgField', 'logging', 'log_actor', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'addPgIndex', 'logging', 'logging_actor_time_backwards', '( log_timestamp, log_actor )' ], + [ 'addPgIndex', 'logging', 'logging_actor_type_time', '( log_actor, log_type, log_timestamp )' ], + [ 'addPgIndex', 'logging', 'logging_actor_time', '( log_actor, log_timestamp )' ], + [ 'migrateActors' ], + [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ], ]; } @@ -730,6 +777,18 @@ END; $this->db->query( "ALTER INDEX $old RENAME TO $new" ); } + protected function dropPgField( $table, $field ) { + $fi = $this->db->fieldInfo( $table, $field ); + if ( is_null( $fi ) ) { + $this->output( "...$table table does not contain $field field.\n" ); + + return; + } else { + $this->output( "Dropping column '$table.$field'\n" ); + $this->db->query( "ALTER TABLE $table DROP COLUMN $field" ); + } + } + protected function addPgField( $table, $field, $type ) { $fi = $this->db->fieldInfo( $table, $field ); if ( !is_null( $fi ) ) { @@ -1006,7 +1065,7 @@ END; } } - protected function dropIndex( $table, $index, $patch = '', $fullpath = false ) { + protected function dropPgIndex( $table, $index ) { if ( $this->db->indexExists( $table, $index ) ) { $this->output( "Dropping obsolete index '$index'\n" ); $this->db->query( "DROP INDEX \"" . $index . "\"" );