mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-25 15:53:09 -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
|
sqlutil.PartitionOffsetStatements
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const createSequence = "CREATE SEQUENCE IF NOT EXISTS syncapi_stream_id;"
|
||||||
|
|
||||||
// NewDatabase creates a new sync server database
|
// NewDatabase creates a new sync server database
|
||||||
func NewDatabase(dbProperties *config.DatabaseOptions) (*SyncServerDatasource, error) {
|
func NewDatabase(dbProperties *config.DatabaseOptions) (*SyncServerDatasource, error) {
|
||||||
var d SyncServerDatasource
|
var d SyncServerDatasource
|
||||||
|
|
@ -46,6 +48,11 @@ func NewDatabase(dbProperties *config.DatabaseOptions) (*SyncServerDatasource, e
|
||||||
}
|
}
|
||||||
d.writer = sqlutil.NewDummyWriter()
|
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,
|
// 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
|
// and THEN prepare statements so we don't fail due to referencing new columns
|
||||||
r := receiptStatements{}
|
r := receiptStatements{}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue