mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 23:03:10 -06:00
Ensure required sequence exists before running migrations
This commit is contained in:
parent
722fe5a046
commit
cbc62d176b
|
|
@ -37,6 +37,8 @@ type SyncServerDatasource struct {
|
|||
sqlutil.PartitionOffsetStatements
|
||||
}
|
||||
|
||||
const createSequence = "CREATE SEQUENCE IF NOT EXISTS syncapi_stream_id;"
|
||||
|
||||
// NewDatabase creates a new sync server database
|
||||
func NewDatabase(dbProperties *config.DatabaseOptions) (*SyncServerDatasource, error) {
|
||||
var d SyncServerDatasource
|
||||
|
|
@ -46,6 +48,11 @@ func NewDatabase(dbProperties *config.DatabaseOptions) (*SyncServerDatasource, e
|
|||
}
|
||||
d.writer = sqlutil.NewDummyWriter()
|
||||
|
||||
// Make sure the required, for most tables, exists.
|
||||
if _, err = d.db.Exec(createSequence); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Create tables before executing migrations so we don't fail if the table is missing,
|
||||
// and THEN prepare statements so we don't fail due to referencing new columns
|
||||
r := receiptStatements{}
|
||||
|
|
|
|||
Loading…
Reference in a new issue