aboutsummaryrefslogtreecommitdiff
path: root/keyserver/storage/sqlite3/key_changes_table.go
diff options
context:
space:
mode:
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) {