wiki.techinc.nl/maintenance/sqlite/archives/patch-protected_titles-pt_title-varbinary.sql
Ammar Abdulhamid 7fbcee5748 Migrate protected_titles to abstract schema
For Postgres:
 - Drop foreign key from pt_title
 - Change pt_user to non-nullable to sync with MySQL
 - Change pt_expiry to non-nullable to sync with MySQL
 - Modify pt_reason_id to use BIGINT to sync with MySQL
 - Drop default from pt_create_perm field since MySQL and SQLite
don't have it and the field is not nullable.
 -

For MySQL/SQLite:
 - Modify pt_title to use varbinary
 - Drop DEFAULT constraint from pt_expiry (Postgres already does not have it)

Bug: T230428
Bug: T164898
Change-Id: Iff193754260046222ba9b7e704c46e27f21b1a6b
2020-11-02 15:05:23 +01:00

19 lines
No EOL
675 B
SQL

CREATE TABLE /*_*/protected_titles_tmp (
pt_namespace INTEGER NOT NULL,
pt_title BLOB NOT NULL,
pt_user INTEGER UNSIGNED NOT NULL,
pt_reason_id BIGINT UNSIGNED NOT NULL,
pt_timestamp BLOB NOT NULL,
pt_expiry BLOB DEFAULT '' NOT NULL,
pt_create_perm BLOB NOT NULL,
PRIMARY KEY(pt_namespace, pt_title)
);
INSERT INTO /*_*/protected_titles_tmp
SELECT pt_namespace, pt_title, pt_user, pt_reason_id, pt_timestamp, pt_expiry, pt_create_perm
FROM /*_*/protected_titles;
DROP TABLE /*_*/protected_titles;
ALTER TABLE /*_*/protected_titles_tmp RENAME TO /*_*/protected_titles;
CREATE INDEX pt_timestamp ON /*_*/protected_titles (pt_timestamp);