diff options
author | Kegsay <kegan@matrix.org> | 2020-10-15 18:09:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-15 18:09:41 +0100 |
commit | 4a7fb9c045211c54c13610119a0f5ed0df355a0f (patch) | |
tree | e54762e0ff1ddef421a41e063b87d239a07b9c45 /userapi/storage/accounts/postgres/accounts_table.go | |
parent | 3e5d38e2849816e00297dbd41d748620deaf3a95 (diff) |
Automatically upgrade databases on startup (#1529)
* Support auto-upgrading accounts DB
* Auto-upgrade device DB deltas
* Support up/downgrading from cmd/goose
* Linting
* Create tables then do migrations then prepare statements
To avoid failing due to some things not existing
* Linting
Diffstat (limited to 'userapi/storage/accounts/postgres/accounts_table.go')
-rw-r--r-- | userapi/storage/accounts/postgres/accounts_table.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/userapi/storage/accounts/postgres/accounts_table.go b/userapi/storage/accounts/postgres/accounts_table.go index 254da84c..4eaa5b58 100644 --- a/userapi/storage/accounts/postgres/accounts_table.go +++ b/userapi/storage/accounts/postgres/accounts_table.go @@ -75,11 +75,12 @@ type accountsStatements struct { serverName gomatrixserverlib.ServerName } +func (s *accountsStatements) execSchema(db *sql.DB) error { + _, err := db.Exec(accountsSchema) + return err +} + func (s *accountsStatements) prepare(db *sql.DB, server gomatrixserverlib.ServerName) (err error) { - _, err = db.Exec(accountsSchema) - if err != nil { - return - } if s.insertAccountStmt, err = db.Prepare(insertAccountSQL); err != nil { return } |