diff options
author | kegsay <kegan@matrix.org> | 2022-01-21 09:56:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-21 09:56:06 +0000 |
commit | 2c581377a5f6b243300445947fd0fd38a919873d (patch) | |
tree | 4aa9948333bbd5f64c1cf0af8294789cfae7a2e9 /keyserver/storage/postgres/storage.go | |
parent | db7d9cba8ad28c300dd66c01b9b0ce2414e8cbe0 (diff) |
Remodel how device list change IDs are created (#2098)
* Remodel how device list change IDs are created
Previously we made them using the offset Kafka supplied.
We don't run Kafka anymore, so now we make the SQL table assign
the change ID via an AUTOINCREMENTing ID. Redesign the
`keyserver_key_changes` table to have `UNIQUE(user_id)` so we
don't accumulate key changes forevermore, we now have at most 1
row per user which contains the highest change ID.
This needs a SQL migration.
* Ensure we bump the change ID on sqlite
* Actually read the DeviceChangeID not the Offset in synapi
* Add SQL migrations
* Prepare after migration; fixup dendrite-upgrade-test logging
* Use higher version numbers; fix sqlite query to increment better
* Default 0 on postgres
* fixup postgres migration on fresh dendrite instances
Diffstat (limited to 'keyserver/storage/postgres/storage.go')
-rw-r--r-- | keyserver/storage/postgres/storage.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/keyserver/storage/postgres/storage.go b/keyserver/storage/postgres/storage.go index 52f3a7f6..b71cc1a7 100644 --- a/keyserver/storage/postgres/storage.go +++ b/keyserver/storage/postgres/storage.go @@ -16,6 +16,7 @@ package postgres import ( "github.com/matrix-org/dendrite/internal/sqlutil" + "github.com/matrix-org/dendrite/keyserver/storage/postgres/deltas" "github.com/matrix-org/dendrite/keyserver/storage/shared" "github.com/matrix-org/dendrite/setup/config" ) @@ -51,6 +52,14 @@ func NewDatabase(dbProperties *config.DatabaseOptions) (*shared.Database, error) if err != nil { return nil, err } + m := sqlutil.NewMigrations() + deltas.LoadRefactorKeyChanges(m) + if err = m.RunDeltas(db, dbProperties); err != nil { + return nil, err + } + if err = kc.Prepare(); err != nil { + return nil, err + } d := &shared.Database{ DB: db, Writer: sqlutil.NewDummyWriter(), |