Check actual postgres error

This commit is contained in:
Till Faelligen 2022-08-08 08:05:22 +02:00
parent c14887ece1
commit 129fb0b030
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E
2 changed files with 23 additions and 0 deletions

View file

@ -18,6 +18,8 @@ import (
"context"
"database/sql"
"github.com/lib/pq"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/keyserver/storage/postgres/deltas"
@ -73,6 +75,16 @@ func NewPostgresKeyChangesTable(db *sql.DB) (tables.KeyChanges, error) {
Up: deltas.UpRefactorKeyChanges,
})
return s, m.Up(context.Background())
} else {
switch e := err.(type) {
case *pq.Error:
// ignore undefined_column (42703) errors, as this is expected at this point
if e.Code == "42703" {
return s, nil
}
default:
return nil, err
}
}
return s, nil
}

View file

@ -19,6 +19,7 @@ import (
"database/sql"
"fmt"
"github.com/lib/pq"
// Import the postgres database driver.
_ "github.com/lib/pq"
@ -65,6 +66,16 @@ func Open(base *base.BaseDendrite, dbProperties *config.DatabaseOptions, cache c
if err = m.Up(base.Context()); err != nil {
return nil, err
}
} else {
switch e := err.(type) {
case *pq.Error:
// ignore undefined_column (42703) errors, as this is expected at this point
if e.Code != "42703" {
return nil, err
}
default:
return nil, err
}
}
// Then prepare the statements. Now that the migrations have run, any columns referred