aboutsummaryrefslogtreecommitdiff
path: root/keyserver/storage/sqlite3/key_changes_table.go
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-07-25 11:39:22 +0200
committerGitHub <noreply@github.com>2022-07-25 10:39:22 +0100
commit081f5e722677fc0306934a814c557b57d56c2e0d (patch)
tree2b38cc172c5f226eeb6cf553a230189f18167c4d /keyserver/storage/sqlite3/key_changes_table.go
parentc7d978274d1e9606574106a9fee63ff555604d1d (diff)
Update database migrations, remove goose (#2264)
* Add new db migration * Update migrations Remove goose * Add possibility to test direct upgrades * Try to fix WASM test * Add checks for specific migrations * Remove AddMigration Use WithTransaction Add Dendrite version to table * Fix linter issues * Update tests * Update comments, outdent if * Namespace migrations * Add direct upgrade tests, skipping over one version * Split migrations * Update go version in CI * Fix copy&paste mistake * Use contexts in migrations Co-authored-by: kegsay <kegan@matrix.org> Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
Diffstat (limited to 'keyserver/storage/sqlite3/key_changes_table.go')
-rw-r--r--keyserver/storage/sqlite3/key_changes_table.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/keyserver/storage/sqlite3/key_changes_table.go b/keyserver/storage/sqlite3/key_changes_table.go
index e035e8c9..1b27c3d0 100644
--- a/keyserver/storage/sqlite3/key_changes_table.go
+++ b/keyserver/storage/sqlite3/key_changes_table.go
@@ -19,6 +19,8 @@ import (
"database/sql"
"github.com/matrix-org/dendrite/internal"
+ "github.com/matrix-org/dendrite/internal/sqlutil"
+ "github.com/matrix-org/dendrite/keyserver/storage/sqlite3/deltas"
"github.com/matrix-org/dendrite/keyserver/storage/tables"
)
@@ -53,7 +55,23 @@ func NewSqliteKeyChangesTable(db *sql.DB) (tables.KeyChanges, error) {
db: db,
}
_, err := db.Exec(keyChangesSchema)
- return s, err
+ if err != nil {
+ return s, err
+ }
+ // TODO: Remove when we are sure we are not having goose artefacts in the db
+ // This forces an error, which indicates the migration is already applied, since the
+ // column partition was removed from the table
+ err = db.QueryRow("SELECT partition FROM keyserver_key_changes LIMIT 1;").Scan()
+ if err == nil {
+ m := sqlutil.NewMigrator(db)
+ m.AddMigrations(sqlutil.Migration{
+ Version: "keyserver: refactor key changes",
+ Up: deltas.UpRefactorKeyChanges,
+ })
+ return s, m.Up(context.Background())
+ }
+
+ return s, nil
}
func (s *keyChangesStatements) Prepare() (err error) {