Merge "Populate ar_rev_id and make it non-nullable"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 3 Apr 2018 15:37:05 +0000 (15:37 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 3 Apr 2018 15:37:05 +0000 (15:37 +0000)
1  2 
autoload.php
includes/installer/MssqlUpdater.php
includes/installer/MysqlUpdater.php
includes/installer/OracleUpdater.php
includes/installer/PostgresUpdater.php
includes/installer/SqliteUpdater.php
maintenance/mssql/tables.sql
maintenance/oracle/tables.sql
maintenance/postgres/tables.sql
maintenance/tables.sql

diff --combined autoload.php
@@@ -366,7 -366,6 +366,7 @@@ $wgAutoloadLocalClasses = 
        'DeleteAction' => __DIR__ . '/includes/actions/DeleteAction.php',
        'DeleteArchivedFiles' => __DIR__ . '/maintenance/deleteArchivedFiles.php',
        'DeleteArchivedRevisions' => __DIR__ . '/maintenance/deleteArchivedRevisions.php',
 +      'DeleteAutoPatrolLogs' => __DIR__ . '/maintenance/deleteAutoPatrolLogs.php',
        'DeleteBatch' => __DIR__ . '/maintenance/deleteBatch.php',
        'DeleteDefaultMessages' => __DIR__ . '/maintenance/deleteDefaultMessages.php',
        'DeleteEqualMessages' => __DIR__ . '/maintenance/deleteEqualMessages.php',
        'PoolCounterWorkViaCallback' => __DIR__ . '/includes/poolcounter/PoolCounterWorkViaCallback.php',
        'PoolCounter_Stub' => __DIR__ . '/includes/poolcounter/PoolCounter.php',
        'PoolWorkArticleView' => __DIR__ . '/includes/poolcounter/PoolWorkArticleView.php',
+       'PopulateArchiveRevId' => __DIR__ . '/maintenance/populateArchiveRevId.php',
        'PopulateBacklinkNamespace' => __DIR__ . '/maintenance/populateBacklinkNamespace.php',
        'PopulateCategory' => __DIR__ . '/maintenance/populateCategory.php',
        'PopulateContentModel' => __DIR__ . '/maintenance/populateContentModel.php',
@@@ -108,9 -108,6 +108,9 @@@ class MssqlUpdater extends DatabaseUpda
  
                        // Should have been in 1.30
                        [ 'addTable', 'comment', 'patch-comment-table.sql' ],
 +                      // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
 +                      [ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
 +                      // Should have been in 1.30
                        [ 'migrateComments' ],
  
                        // 1.31
                        [ 'migrateActors' ],
                        [ 'modifyField', 'revision', 'rev_text_id', 'patch-rev_text_id-default.sql' ],
                        [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
+                       [ 'populateArchiveRevId' ],
                ];
        }
  
@@@ -325,10 -325,6 +325,10 @@@ class MysqlUpdater extends DatabaseUpda
                        [ 'renameIndex', 'user_properties', 'user_properties_user_property', 'PRIMARY', false,
                                'patch-user_properties-fix-pk.sql' ],
                        [ 'addTable', 'comment', 'patch-comment-table.sql' ],
 +
 +                      // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
 +                      [ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
 +
                        [ 'migrateComments' ],
                        [ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
                                'patch-l10n_cache-primary-key.sql' ],
                        [ 'migrateActors' ],
                        [ 'modifyField', 'revision', 'rev_text_id', 'patch-rev_text_id-default.sql' ],
                        [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
+                       [ 'populateArchiveRevId' ],
                ];
        }
  
@@@ -129,9 -129,6 +129,9 @@@ class OracleUpdater extends DatabaseUpd
  
                        // Should have been in 1.30
                        [ 'addTable', 'comment', 'patch-comment-table.sql' ],
 +                      // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
 +                      [ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
 +                      // Should have been in 1.30
                        [ 'migrateComments' ],
  
                        // 1.31
                        [ 'addTable', 'actor', 'patch-actor-table.sql' ],
                        [ 'migrateActors' ],
                        [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
+                       [ 'populateArchiveRevId' ],
  
                        // KEEP THIS AT THE BOTTOM!!
                        [ 'doRebuildDuplicateFunction' ],
@@@ -481,10 -481,6 +481,10 @@@ class PostgresUpdater extends DatabaseU
                        [ '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' ],
                        [ 'addPgIndex', 'logging', 'logging_actor_time', '( log_actor, log_timestamp )' ],
                        [ 'migrateActors' ],
                        [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
+                       [ 'populateArchiveRevId' ],
                ];
        }
  
@@@ -190,10 -190,6 +190,10 @@@ class SqliteUpdater extends DatabaseUpd
                        [ 'renameIndex', 'user_properties', 'user_properties_user_property', 'PRIMARY', false,
                                'patch-user_properties-fix-pk.sql' ],
                        [ 'addTable', 'comment', 'patch-comment-table.sql' ],
 +
 +                      // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
 +                      [ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
 +
                        [ 'migrateComments' ],
                        [ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
                                'patch-l10n_cache-primary-key.sql' ],
                        [ 'migrateActors' ],
                        [ 'modifyField', 'revision', 'rev_text_id', 'patch-rev_text_id-default.sql' ],
                        [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
+                       [ 'populateArchiveRevId' ],
                ];
        }
  
@@@ -279,7 -279,7 +279,7 @@@ CREATE TABLE /*_*/archive 
     ar_timestamp varchar(14) NOT NULL default '',
     ar_minor_edit BIT NOT NULL DEFAULT 0,
     ar_flags NVARCHAR(255) NOT NULL,
-    ar_rev_id INT NULL, -- NOT a FK, the row gets deleted from revision and moved here
+    ar_rev_id INT NOT NULL, -- NOT a FK, the row gets deleted from revision and moved here
     ar_text_id INT CONSTRAINT ar_text_id__old_id__fk FOREIGN KEY REFERENCES /*_*/text(old_id) ON DELETE CASCADE,
     ar_deleted TINYINT NOT NULL DEFAULT 0,
     ar_len INT,
@@@ -736,7 -736,6 +736,7 @@@ CREATE TABLE /*_*/image 
    -- Description field as entered by the uploader.
    -- This is displayed in image upload history and logs.
    img_description nvarchar(255) NOT NULL CONSTRAINT DF_img_description DEFAULT '',
 +  img_description_id bigint NOT NULL CONSTRAINT DF_img_description_id DEFAULT 0 CONSTRAINT FK_img_description_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
  
    -- user_id and user_name of uploader.
    img_user int REFERENCES /*_*/mwuser(user_id) ON DELETE SET NULL,
@@@ -257,7 -257,7 +257,7 @@@ CREATE TABLE &mw_prefix.archive 
    ar_timestamp   TIMESTAMP(6) WITH TIME ZONE  NOT NULL,
    ar_minor_edit  CHAR(1)         DEFAULT '0' NOT NULL,
    ar_flags       VARCHAR2(255),
-   ar_rev_id      NUMBER,
+   ar_rev_id      NUMBER NOT NULL,
    ar_text_id     NUMBER,
    ar_deleted     CHAR(1)      DEFAULT '0' NOT NULL,
    ar_len         NUMBER,
@@@ -517,7 -517,6 +517,7 @@@ CREATE TABLE &mw_prefix.image 
    img_major_mime   VARCHAR2(32) DEFAULT 'unknown',
    img_minor_mime   VARCHAR2(100) DEFAULT 'unknown',
    img_description  VARCHAR2(255),
 +  img_description_id  NUMBER DEFAULT 0 NOT NULL,
    img_user         NUMBER       DEFAULT 0 NOT NULL,
    img_user_text    VARCHAR2(255)      NULL,
    img_actor        NUMBER       DEFAULT 0 NOT NULL,
  );
  ALTER TABLE &mw_prefix.image ADD CONSTRAINT &mw_prefix.image_pk PRIMARY KEY (img_name);
  ALTER TABLE &mw_prefix.image ADD CONSTRAINT &mw_prefix.image_fk1 FOREIGN KEY (img_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 +ALTER TABLE &mw_prefix.image ADD CONSTRAINT &mw_prefix.image_fk2 FOREIGN KEY (img_description_id) REFERENCES &mw_prefix."COMMENT"(comment_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
  CREATE INDEX &mw_prefix.image_i01 ON &mw_prefix.image (img_user_text,img_timestamp);
  CREATE INDEX &mw_prefix.image_i02 ON &mw_prefix.image (img_size);
  CREATE INDEX &mw_prefix.image_i03 ON &mw_prefix.image (img_timestamp);
@@@ -248,7 -248,7 +248,7 @@@ CREATE TABLE archive 
    ar_timestamp      TIMESTAMPTZ  NOT NULL,
    ar_minor_edit     SMALLINT     NOT NULL  DEFAULT 0,
    ar_flags          TEXT,
-   ar_rev_id         INTEGER,
+   ar_rev_id         INTEGER      NOT NULL,
    ar_text_id        INTEGER,
    ar_deleted        SMALLINT     NOT NULL  DEFAULT 0,
    ar_len            INTEGER          NULL,
@@@ -421,7 -421,6 +421,7 @@@ CREATE TABLE image 
    img_major_mime   TEXT                DEFAULT 'unknown',
    img_minor_mime   TEXT                DEFAULT 'unknown',
    img_description  TEXT      NOT NULL  DEFAULT '',
 +  img_description_id INTEGER NOT NULL  DEFAULT 0,
    img_user         INTEGER   NOT NULL  DEFAULT 0 REFERENCES mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
    img_user_text    TEXT      NOT NULL  DEFAULT '',
    img_actor        INTEGER   NOT NULL  DEFAULT 0,
diff --combined maintenance/tables.sql
@@@ -618,7 -618,7 +618,7 @@@ CREATE TABLE /*_*/archive 
    --
    -- @since 1.5 Entries from 1.4 will be NULL here. When restoring
    -- archive rows from before 1.5, a new rev_id is created.
-   ar_rev_id int unsigned,
+   ar_rev_id int unsigned NOT NULL,
  
    -- Copied from rev_text_id, references text.old_id.
    -- To avoid breaking the block-compression scheme and otherwise making
@@@ -1167,11 -1167,9 +1167,11 @@@ CREATE TABLE /*_*/image 
  
    -- Description field as entered by the uploader.
    -- This is displayed in image upload history and logs.
 -  -- Deprecated in favor of image_comment_temp.imgcomment_description_id.
 +  -- Deprecated in favor of img_description_id.
    img_description varbinary(767) NOT NULL default '',
  
 +  img_description_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that img_description should be used)
 +
    -- user_id and user_name of uploader.
    -- Deprecated in favor of img_actor.
    img_user int unsigned NOT NULL default 0,