From 89663c274510a31cf91fa314fca1d1428a28fac7 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Mon, 16 May 2022 21:22:09 -0600 Subject: [PATCH] backfill state: add table for tracking state --- .../2022-05-16-room-backfill-state.go | 25 +++++++++++++++++++ database/upgrades/upgrades.go | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 database/upgrades/2022-05-16-room-backfill-state.go diff --git a/database/upgrades/2022-05-16-room-backfill-state.go b/database/upgrades/2022-05-16-room-backfill-state.go new file mode 100644 index 0000000..f7de55f --- /dev/null +++ b/database/upgrades/2022-05-16-room-backfill-state.go @@ -0,0 +1,25 @@ +package upgrades + +import ( + "database/sql" +) + +func init() { + upgrades[46] = upgrade{"Create the backfill state table", func(tx *sql.Tx, ctx context) error { + _, err := tx.Exec(` + CREATE TABLE backfill_state ( + user_mxid TEXT, + portal_jid TEXT, + portal_receiver TEXT, + processing_batch BOOLEAN, + backfill_complete BOOLEAN, + first_expected_ts TIMESTAMP, + + 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 + ) + `) + return err + }} +} diff --git a/database/upgrades/upgrades.go b/database/upgrades/upgrades.go index 0514cc9..eba9df8 100644 --- a/database/upgrades/upgrades.go +++ b/database/upgrades/upgrades.go @@ -40,7 +40,7 @@ type upgrade struct { fn upgradeFunc } -const NumberOfUpgrades = 46 +const NumberOfUpgrades = 47 var upgrades [NumberOfUpgrades]upgrade