diff options
author | Amir Sarabadani <Ladsgroup@gmail.com> | 2020-08-29 19:00:04 +0200 |
---|---|---|
committer | Amir Sarabadani <Ladsgroup@gmail.com> | 2020-09-05 19:29:23 +0200 |
commit | 1770341562c515057ab144949a773425c0914705 (patch) | |
tree | 0951688ed083c7d630bb1673826533f0f9618053 /maintenance/postgres | |
parent | cb3597be843b3f61a92a312a9bd770f44444d05a (diff) | |
download | mediawikicore-1770341562c515057ab144949a773425c0914705.tar.gz mediawikicore-1770341562c515057ab144949a773425c0914705.zip |
Migrate langlinks to abstract schema
In order to migrate MySQL and Sqlite to abstract schema changed the
ll_title data type from varchar binary to varbinary. This wouldn't
affect production.
For migrating Postgres:
- Dropping foreign key on ll_from
- Setting default of empty string for ll_lang and ll_title
- Make ll_lang and ll_title both non-nullable to be in sync with MySQL
- Turning the unique index to primary key, similar to MySQL
- Renaming an index to sync with MySQL
Bug: T164898
Bug: T230428
Change-Id: I57f22896ff67266f99bf08f6dd1b9cc4c51b1db9
Diffstat (limited to 'maintenance/postgres')
-rw-r--r-- | maintenance/postgres/archives/patch-langlinks-pk.sql | 3 | ||||
-rw-r--r-- | maintenance/postgres/tables-generated.sql | 10 | ||||
-rw-r--r-- | maintenance/postgres/tables.sql | 8 |
3 files changed, 13 insertions, 8 deletions
diff --git a/maintenance/postgres/archives/patch-langlinks-pk.sql b/maintenance/postgres/archives/patch-langlinks-pk.sql new file mode 100644 index 000000000000..b3a6ea21febd --- /dev/null +++ b/maintenance/postgres/archives/patch-langlinks-pk.sql @@ -0,0 +1,3 @@ +DROP INDEX langlinks_unique; +ALTER TABLE langlinks + ADD PRIMARY KEY (ll_from,ll_lang); diff --git a/maintenance/postgres/tables-generated.sql b/maintenance/postgres/tables-generated.sql index f0586d8d5281..e7d45b831dc3 100644 --- a/maintenance/postgres/tables-generated.sql +++ b/maintenance/postgres/tables-generated.sql @@ -210,3 +210,13 @@ CREATE INDEX il_to ON imagelinks (il_to, il_from); CREATE INDEX il_backlinks_namespace ON imagelinks ( il_from_namespace, il_to, il_from ); + + +CREATE TABLE langlinks ( + ll_from INT DEFAULT 0 NOT NULL, + ll_lang TEXT DEFAULT '' NOT NULL, + ll_title TEXT DEFAULT '' NOT NULL, + PRIMARY KEY(ll_from, ll_lang) +); + +CREATE INDEX ll_lang ON langlinks (ll_lang, ll_title); diff --git a/maintenance/postgres/tables.sql b/maintenance/postgres/tables.sql index 1eea48a522ad..7d4a5dce0288 100644 --- a/maintenance/postgres/tables.sql +++ b/maintenance/postgres/tables.sql @@ -273,14 +273,6 @@ CREATE INDEX externallinks_index ON externallinks (el_index); CREATE INDEX el_index_60 ON externallinks (el_index_60, el_id); CREATE INDEX el_from_index_60 ON externallinks (el_from, el_index_60, el_id); -CREATE TABLE langlinks ( - ll_from INTEGER NOT NULL REFERENCES page (page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, - ll_lang TEXT, - ll_title TEXT -); -CREATE UNIQUE INDEX langlinks_unique ON langlinks (ll_from,ll_lang); -CREATE INDEX langlinks_lang_title ON langlinks (ll_lang,ll_title); - CREATE SEQUENCE ipblocks_ipb_id_seq; CREATE TABLE ipblocks ( ipb_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('ipblocks_ipb_id_seq'), |