Fix drifts in columns of recentchanges in PG

To make abstracting this table easier. Reducing the schema drift between
schema of this table in PG and MySQL:
 - Changing datatype of four fields
 - Set default for seven fields
 - Change nullability of two fields.

Bug: T230428
Bug: T164898
Change-Id: Id6fa9fd1ebf840f6354fcd8b8ebf0e393ba9e624
This commit is contained in:
Amir Sarabadani 2021-02-06 01:19:00 +01:00
parent 5dc879321b
commit 6809067ef3
2 changed files with 22 additions and 9 deletions

View file

@ -918,6 +918,19 @@ class PostgresUpdater extends DatabaseUpdater {
[ 'addPgIndex', 'image', 'img_media_mime', '(img_media_type, img_major_mime, img_minor_mime)' ],
[ 'renameIndex', 'site_identifiers', 'site_ids_site', 'si_site' ],
[ 'renameIndex', 'site_identifiers', 'site_ids_key', 'si_key' ],
[ 'changeField', 'recentchanges', 'rc_actor', 'BIGINT', '' ],
[ 'changeField', 'recentchanges', 'rc_comment_id', 'BIGINT', '' ],
[ 'changeField', 'recentchanges', 'rc_ip', 'TEXT', '' ],
[ 'changeField', 'recentchanges', 'rc_namespace', 'INTEGER', '' ],
[ 'setDefault', 'recentchanges', 'rc_title', '' ],
[ 'setDefault', 'recentchanges', 'rc_source', '' ],
[ 'setDefault', 'recentchanges', 'rc_ip', '' ],
[ 'setDefault', 'recentchanges', 'rc_namespace', 0 ],
[ 'setDefault', 'recentchanges', 'rc_cur_id', 0 ],
[ 'setDefault', 'recentchanges', 'rc_this_oldid', 0 ],
[ 'setDefault', 'recentchanges', 'rc_last_oldid', 0 ],
[ 'changeNullableField', 'recentchanges', 'rc_cur_id', 'NOT NULL', true ],
[ 'changeNullableField', 'recentchanges', 'rc_ip', 'NOT NULL', true ],
];
}

View file

@ -120,20 +120,20 @@ CREATE SEQUENCE recentchanges_rc_id_seq;
CREATE TABLE recentchanges (
rc_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('recentchanges_rc_id_seq'),
rc_timestamp TIMESTAMPTZ NOT NULL,
rc_actor INTEGER NOT NULL,
rc_namespace SMALLINT NOT NULL,
rc_title TEXT NOT NULL,
rc_comment_id INTEGER NOT NULL,
rc_actor BIGINT NOT NULL,
rc_namespace INTEGER NOT NULL DEFAULT 0,
rc_title TEXT NOT NULL DEFAULT '',
rc_comment_id BIGINT NOT NULL,
rc_minor SMALLINT NOT NULL DEFAULT 0,
rc_bot SMALLINT NOT NULL DEFAULT 0,
rc_new SMALLINT NOT NULL DEFAULT 0,
rc_cur_id INTEGER NULL,
rc_this_oldid INTEGER NOT NULL,
rc_last_oldid INTEGER NOT NULL,
rc_cur_id INTEGER NOT NULL DEFAULT 0,
rc_this_oldid INTEGER NOT NULL DEFAULT 0,
rc_last_oldid INTEGER NOT NULL DEFAULT 0,
rc_type SMALLINT NOT NULL DEFAULT 0,
rc_source TEXT NOT NULL,
rc_source TEXT NOT NULL DEFAULT '',
rc_patrolled SMALLINT NOT NULL DEFAULT 0,
rc_ip CIDR,
rc_ip TEXT NOT NULL DEFAULT '',
rc_old_len INTEGER,
rc_new_len INTEGER,
rc_deleted SMALLINT NOT NULL DEFAULT 0,