wiki.techinc.nl/maintenance/sqlite/archives/patch-content_models-model_id-fix_not_null.sql
Amir Sarabadani a2a0088d6b Migrate slot_roles and content_models to abstract schema
These tables don't have drift between MySQL and Postgres but their
primary keys don't have explicit "NOT NULL" statement making them
nullable in sqlite. Fixing this drift.

Also changing the PK fields of these two tables from smallint to int,
given that PG would be complicated with smallint auto_increment PKs

Bug: T230428
Bug: T258366
Change-Id: Icf6ce044eaf0f09b1a2bdd8a1f618cef1e0415bf
2020-11-22 00:24:08 +01:00

11 lines
385 B
SQL

CREATE TABLE /*_*/content_models_tmp (
model_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
model_name BLOB NOT NULL
);
INSERT INTO /*_*/content_models_tmp
SELECT model_id, model_name
FROM /*_*/content_models;
DROP TABLE /*_*/content_models;
ALTER TABLE /*_*/content_models_tmp RENAME TO /*_*/content_models;
CREATE UNIQUE INDEX model_name ON /*_*/content_models (model_name);