wiki.techinc.nl/maintenance/sqlite/archives/patch-imagelinks-il_to-varbinary.sql
Amir Sarabadani 61eaa48f3c Migrate imagelinks table to abstract schema
In order to migrate MySQL and Sqlite to abstract schema changed the
il_to data type from varchar binary to varbinary. This wouldn't
affect production.

For migrating Postgres:
 - Dropping foreign key on il_from
 - Setting default of empty string for il_to
 - Completely rewriting indexes to make it synced with MySQL

Bug: T164898
Bug: T230428
Change-Id: I59f0d0a56d938a168bf1c7de2a1be47f15d1add1
2020-08-22 22:59:00 +02:00

18 lines
537 B
SQL

CREATE TABLE /*_*/imagelinks_tmp (
il_from INTEGER UNSIGNED DEFAULT 0 NOT NULL,
il_to BLOB DEFAULT '' NOT NULL,
il_from_namespace INTEGER DEFAULT 0 NOT NULL,
PRIMARY KEY(il_from, il_to)
);
INSERT INTO /*_*/imagelinks_tmp
SELECT il_from, il_to, il_from_namespace
FROM /*_*/imagelinks;
DROP TABLE /*_*/imagelinks;
ALTER TABLE /*_*/imagelinks_tmp RENAME TO /*_*/imagelinks;
CREATE INDEX il_to ON /*_*/imagelinks (il_to, il_from);
CREATE INDEX il_backlinks_namespace ON /*_*/imagelinks (
il_from_namespace, il_to, il_from
);