aboutsummaryrefslogtreecommitdiff
path: root/userapi/storage/accounts/postgres/accounts_table.go
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-10-15 18:09:41 +0100
committerGitHub <noreply@github.com>2020-10-15 18:09:41 +0100
commit4a7fb9c045211c54c13610119a0f5ed0df355a0f (patch)
treee54762e0ff1ddef421a41e063b87d239a07b9c45 /userapi/storage/accounts/postgres/accounts_table.go
parent3e5d38e2849816e00297dbd41d748620deaf3a95 (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.go9
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
}