From 4a7fb9c045211c54c13610119a0f5ed0df355a0f Mon Sep 17 00:00:00 2001 From: Kegsay Date: Thu, 15 Oct 2020 18:09:41 +0100 Subject: 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 --- userapi/storage/accounts/postgres/accounts_table.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'userapi/storage/accounts/postgres/accounts_table.go') 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 } -- cgit v1.2.3