mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-22 05:23:09 -06:00
Fail to start if we get a non-uniqueconstraint error
This commit is contained in:
parent
240d00e2b6
commit
d7171e1483
|
|
@ -18,8 +18,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/internal"
|
"github.com/matrix-org/dendrite/internal"
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
|
|
@ -81,8 +80,7 @@ func executeMigration(ctx context.Context, db *sql.DB) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) { // migration was already executed, as the column was removed
|
if errors.Is(err, sql.ErrNoRows) { // migration was already executed, as the column was removed
|
||||||
if err = sqlutil.InsertMigration(ctx, db, migrationName); err != nil {
|
if err = sqlutil.InsertMigration(ctx, db, migrationName); err != nil {
|
||||||
// not a fatal error, log and continue
|
return fmt.Errorf("unable to manually insert migration '%s': %w", migrationName, err)
|
||||||
logrus.WithError(err).Warnf("unable to manually insert migration '%s'", migrationName)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/internal"
|
"github.com/matrix-org/dendrite/internal"
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
|
|
@ -80,8 +79,7 @@ func executeMigration(ctx context.Context, db *sql.DB) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) { // migration was already executed, as the column was removed
|
if errors.Is(err, sql.ErrNoRows) { // migration was already executed, as the column was removed
|
||||||
if err = sqlutil.InsertMigration(ctx, db, migrationName); err != nil {
|
if err = sqlutil.InsertMigration(ctx, db, migrationName); err != nil {
|
||||||
// not a fatal error, log and continue
|
return fmt.Errorf("unable to manually insert migration '%s': %w", migrationName, err)
|
||||||
logrus.WithError(err).Warnf("unable to manually insert migration '%s'", migrationName)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
// Import the postgres database driver.
|
// Import the postgres database driver.
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
|
|
||||||
|
|
@ -79,8 +77,7 @@ func executeMigration(ctx context.Context, db *sql.DB) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) { // migration was already executed, as the column was removed
|
if errors.Is(err, sql.ErrNoRows) { // migration was already executed, as the column was removed
|
||||||
if err = sqlutil.InsertMigration(ctx, db, migrationName); err != nil {
|
if err = sqlutil.InsertMigration(ctx, db, migrationName); err != nil {
|
||||||
// not a fatal error, log and continue
|
return fmt.Errorf("unable to manually insert migration '%s': %w", migrationName, err)
|
||||||
logrus.WithError(err).Warnf("unable to manually insert migration '%s'", migrationName)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/internal/caching"
|
"github.com/matrix-org/dendrite/internal/caching"
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
|
|
@ -87,8 +86,7 @@ func executeMigration(ctx context.Context, db *sql.DB) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) { // migration was already executed, as the column was removed
|
if errors.Is(err, sql.ErrNoRows) { // migration was already executed, as the column was removed
|
||||||
if err = sqlutil.InsertMigration(ctx, db, migrationName); err != nil {
|
if err = sqlutil.InsertMigration(ctx, db, migrationName); err != nil {
|
||||||
// not a fatal error, log and continue
|
return fmt.Errorf("unable to manually insert migration '%s': %w", migrationName, err)
|
||||||
logrus.WithError(err).Warnf("unable to manually insert migration '%s'", migrationName)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue