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

For migrating Postgres, renamed two indexes from category_* to cat_* to
make it in sync with MySQL/Sqlite

Bug: T164898
Bug: T230428
Change-Id: Iad11aa4f7d809465cb20ac9748bf52b0e1bcd5a4
2020-09-05 20:49:12 +02:00

15 lines
545 B
SQL

CREATE TABLE /*_*/category_tmp (
cat_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
cat_title BLOB NOT NULL,
cat_pages INTEGER DEFAULT 0 NOT NULL,
cat_subcats INTEGER DEFAULT 0 NOT NULL,
cat_files INTEGER DEFAULT 0 NOT NULL
);
INSERT INTO /*_*/category_tmp
SELECT cat_id, cat_title, cat_pages, cat_subcats, cat_files
FROM /*_*/category;
DROP TABLE /*_*/category;
ALTER TABLE /*_*/category_tmp RENAME TO /*_*/category;
CREATE UNIQUE INDEX cat_title ON /*_*/category (cat_title);
CREATE INDEX cat_pages ON /*_*/category (cat_pages);