mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-14 09:23:51 +01:00
Actually fix first_expected_ts upgrade. Fixes #504
This commit is contained in:
parent
241de2f18f
commit
52748374b7
3 changed files with 15 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
|||
-- v0 -> v48: Latest revision
|
||||
-- v0 -> v49: Latest revision
|
||||
|
||||
CREATE TABLE "user" (
|
||||
mxid TEXT PRIMARY KEY,
|
||||
|
@ -127,7 +127,7 @@ CREATE TABLE backfill_state (
|
|||
portal_receiver TEXT,
|
||||
processing_batch BOOLEAN,
|
||||
backfill_complete BOOLEAN,
|
||||
first_expected_ts TIMESTAMP,
|
||||
first_expected_ts BIGINT,
|
||||
PRIMARY KEY (user_mxid, portal_jid, portal_receiver),
|
||||
FOREIGN KEY (user_mxid) REFERENCES "user" (mxid) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (portal_jid, portal_receiver) REFERENCES portal (jid, receiver) ON DELETE CASCADE
|
||||
|
|
|
@ -6,7 +6,7 @@ CREATE TABLE backfill_state (
|
|||
portal_receiver TEXT,
|
||||
processing_batch BOOLEAN,
|
||||
backfill_complete BOOLEAN,
|
||||
first_expected_ts TIMESTAMP,
|
||||
first_expected_ts INTEGER,
|
||||
PRIMARY KEY (user_mxid, portal_jid, portal_receiver),
|
||||
FOREIGN KEY (user_mxid) REFERENCES "user" (mxid) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (portal_jid, portal_receiver) REFERENCES portal (jid, receiver) ON DELETE CASCADE
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
-- v49: Convert first_expected_ts to BIGINT so that we can use zero-values.
|
||||
|
||||
-- only: sqlite
|
||||
UPDATE backfill_state SET first_expected_ts=unixepoch(first_expected_ts);
|
||||
|
||||
-- v49: Convert first_expected_ts to BIGINT
|
||||
-- only: postgres
|
||||
ALTER TABLE backfill_state ALTER COLUMN first_expected_ts TYPE BIGINT USING extract(epoch from first_expected_ts);
|
||||
|
||||
DO
|
||||
$do$
|
||||
BEGIN
|
||||
IF (SELECT data_type FROM information_schema.columns WHERE table_name='backfill_state' AND column_name='first_expected_ts') = 'integer' THEN
|
||||
ALTER TABLE backfill_state ALTER COLUMN first_expected_ts TYPE BIGINT;
|
||||
ELSE
|
||||
ALTER TABLE backfill_state ALTER COLUMN first_expected_ts TYPE BIGINT USING EXTRACT(EPOCH FROM first_expected_ts);
|
||||
END IF;
|
||||
END
|
||||
$do$
|
||||
|
|
Loading…
Reference in a new issue