backfill state: add table for tracking state

This commit is contained in:
Sumner Evans 2022-05-16 21:22:09 -06:00
parent feb9f71cb5
commit 89663c2745
No known key found for this signature in database
GPG key ID: 8904527AB50022FD
2 changed files with 26 additions and 1 deletions

View file

@ -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
}}
}

View file

@ -40,7 +40,7 @@ type upgrade struct {
fn upgradeFunc fn upgradeFunc
} }
const NumberOfUpgrades = 46 const NumberOfUpgrades = 47
var upgrades [NumberOfUpgrades]upgrade var upgrades [NumberOfUpgrades]upgrade