wiki.techinc.nl/maintenance/sqlite/archives/patch-slot_roles-role_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
351 B
SQL

CREATE TABLE /*_*/slot_roles_tmp (
role_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
role_name BLOB NOT NULL
);
INSERT INTO /*_*/slot_roles_tmp
SELECT role_id, role_name
FROM /*_*/slot_roles;
DROP TABLE /*_*/slot_roles;
ALTER TABLE /*_*/slot_roles_tmp RENAME TO /*_*/slot_roles;
CREATE UNIQUE INDEX role_name ON /*_*/slot_roles (role_name);