aboutsummaryrefslogtreecommitdiff
path: root/keyserver/storage/postgres/key_changes_table.go
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-09-13 08:07:43 +0200
committerGitHub <noreply@github.com>2022-09-13 08:07:43 +0200
commit100fa9b2354efa05b4fbff3a3cb745ea7783d41c (patch)
tree0cd221d7d313a1f000637f981b1c0397f3f856cf /keyserver/storage/postgres/key_changes_table.go
parent62afb936a5d282d0f500645c3442c1c294d37bdb (diff)
Check unique constraint errors when manually inserting migrations (#2712)
This should avoid unnecessary logging on startup if the migration (were we need `InsertMigration`) was already executed. This now checks for "unique constraint errors" for SQLite and Postgres and fails the startup process if the migration couldn't be manually inserted for some other reason.
Diffstat (limited to 'keyserver/storage/postgres/key_changes_table.go')
-rw-r--r--keyserver/storage/postgres/key_changes_table.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/keyserver/storage/postgres/key_changes_table.go b/keyserver/storage/postgres/key_changes_table.go
index e91b048d..c0e3429c 100644
--- a/keyserver/storage/postgres/key_changes_table.go
+++ b/keyserver/storage/postgres/key_changes_table.go
@@ -18,8 +18,7 @@ import (
"context"
"database/sql"
"errors"
-
- "github.com/sirupsen/logrus"
+ "fmt"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/sqlutil"
@@ -81,8 +80,7 @@ func executeMigration(ctx context.Context, db *sql.DB) error {
if err != nil {
if errors.Is(err, sql.ErrNoRows) { // migration was already executed, as the column was removed
if err = sqlutil.InsertMigration(ctx, db, migrationName); err != nil {
- // not a fatal error, log and continue
- logrus.WithError(err).Warnf("unable to manually insert migration '%s'", migrationName)
+ return fmt.Errorf("unable to manually insert migration '%s': %w", migrationName, err)
}
return nil
}