wiki.techinc.nl/maintenance/sqlite/archives/patch-ip_changes-pc_rev_timestamp-drop-default.sql
Amir Sarabadani b14f9ead33 Migrate ip_changes to abstract schema
In order to make Postgres work:
 - Dropped the autoincrement sequence, this is the PK without
   autoincrement
 - Change ipc_hex from BYTEA to TEXT
 - Set default for ipc_rev_id

MySQL/SQLite:
 -Drop default for ipc_rev_timestamp

Bug: T230428
Bug: T164898
Change-Id: I7f85d65f6ee3ac8b1d28e33095f37dce81e1727e
2020-11-05 22:38:50 +01:00

17 lines
526 B
SQL

CREATE TABLE /*_*/ip_changes_tmp (
ipc_rev_id INTEGER UNSIGNED DEFAULT 0 NOT NULL,
ipc_rev_timestamp BLOB NOT NULL,
ipc_hex BLOB DEFAULT '' NOT NULL,
PRIMARY KEY(ipc_rev_id)
);
INSERT INTO /*_*/ip_changes_tmp
SELECT ipc_rev_id, ipc_rev_timestamp, ipc_hex
FROM /*_*/ip_changes;
DROP TABLE /*_*/ip_changes;
ALTER TABLE /*_*/ip_changes_tmp RENAME TO /*_*/ip_changes;
CREATE INDEX ipc_rev_timestamp ON /*_*/ip_changes (ipc_rev_timestamp);
CREATE INDEX ipc_hex_time ON /*_*/ip_changes (ipc_hex, ipc_rev_timestamp);