X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Finstaller%2FPostgresUpdater.php;h=07aeb13d1d74eebd516a09a9061bfcef909dbd23;hp=39cb89cd49968d9b2616d1fbc3c0ba8c266129d7;hb=bc12345f4bb7893030c31e1133abc4b20153f59b;hpb=1ffbcb0b8f8d9555c3c99d76c22ac64a40ab9b0e diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index 39cb89cd49..07aeb13d1d 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -452,6 +452,35 @@ class PostgresUpdater extends DatabaseUpdater { [ 'addPgIndex', 'externallinks', 'el_from_index_60', '( el_from, el_index_60, el_id )' ], [ 'addPgField', 'user_groups', 'ug_expiry', "TIMESTAMPTZ NULL" ], [ 'addPgIndex', 'user_groups', 'user_groups_expiry', '( ug_expiry )' ], + + // 1.30 + [ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ], + [ 'setDefault', 'revision', 'rev_comment', '' ], + [ 'changeNullableField', 'revision', 'rev_comment', 'NOT NULL', true ], + [ 'setDefault', 'archive', 'ar_comment', '' ], + [ 'changeNullableField', 'archive', 'ar_comment', 'NOT NULL', true ], + [ 'addPgField', 'archive', 'ar_comment_id', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'setDefault', 'ipblocks', 'ipb_reason', '' ], + [ 'addPgField', 'ipblocks', 'ipb_reason_id', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'setDefault', 'image', 'img_description', '' ], + [ 'setDefault', 'oldimage', 'oi_description', '' ], + [ 'changeNullableField', 'oldimage', 'oi_description', 'NOT NULL', true ], + [ 'addPgField', 'oldimage', 'oi_description_id', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'setDefault', 'filearchive', 'fa_deleted_reason', '' ], + [ 'changeNullableField', 'filearchive', 'fa_deleted_reason', 'NOT NULL', true ], + [ 'addPgField', 'filearchive', 'fa_deleted_reason_id', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'setDefault', 'filearchive', 'fa_description', '' ], + [ 'addPgField', 'filearchive', 'fa_description_id', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'setDefault', 'recentchanges', 'rc_comment', '' ], + [ 'changeNullableField', 'recentchanges', 'rc_comment', 'NOT NULL', true ], + [ 'addPgField', 'recentchanges', 'rc_comment_id', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'setDefault', 'logging', 'log_comment', '' ], + [ 'changeNullableField', 'logging', 'log_comment', 'NOT NULL', true ], + [ 'addPgField', 'logging', 'log_comment_id', 'INTEGER NOT NULL DEFAULT 0' ], + [ 'setDefault', 'protected_titles', 'pt_reason', '' ], + [ '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' ], ]; } @@ -751,15 +780,15 @@ END; } protected function setDefault( $table, $field, $default ) { - $info = $this->db->fieldInfo( $table, $field ); if ( $info->defaultValue() !== $default ) { $this->output( "Changing '$table.$field' default value\n" ); - $this->db->query( "ALTER TABLE $table ALTER $field SET DEFAULT " . $default ); + $this->db->query( "ALTER TABLE $table ALTER $field SET DEFAULT " + . $this->db->addQuotes( $default ) ); } } - protected function changeNullableField( $table, $field, $null ) { + protected function changeNullableField( $table, $field, $null, $update = false ) { $fi = $this->db->fieldInfo( $table, $field ); if ( is_null( $fi ) ) { $this->output( "...ERROR: expected column $table.$field to exist\n" ); @@ -769,6 +798,9 @@ END; # # It's NULL - does it need to be NOT NULL? if ( 'NOT NULL' === $null ) { $this->output( "Changing '$table.$field' to not allow NULLs\n" ); + if ( $update ) { + $this->db->query( "UPDATE $table SET $field = DEFAULT WHERE $field IS NULL" ); + } $this->db->query( "ALTER TABLE $table ALTER $field SET NOT NULL" ); } else { $this->output( "...column '$table.$field' is already set as NULL\n" );