diff options
-rw-r--r-- | model/database.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/model/database.go b/model/database.go index b6e64bb..85d2662 100644 --- a/model/database.go +++ b/model/database.go @@ -78,7 +78,7 @@ func isDatabaseEmpty(tx *sql.Tx) bool { return number == 0 } -func setupMinimalDatabase(tx *sql.Tx, version string) error { +func setupMinimalDatabase(tx *sql.Tx, execVersion string) error { cmd := ` CREATE TABLE metadata ( key TEXT PRIMARY KEY, @@ -89,7 +89,7 @@ INSERT INTO metadata VALUES ('version', ?); ` - _, err := tx.Exec(cmd, version) + _, err := tx.Exec(cmd, execVersion) return err } @@ -113,11 +113,11 @@ func getDatabaseVersion(tx *sql.Tx) string { return version } -func MigrateDatabase(version string) { +func MigrateDatabase(execVersion string) { err := Transaction(func(tx *sql.Tx) error { if isDatabaseEmpty(tx) { log.Println("Starting with empty database") - err := setupMinimalDatabase(tx, version) + err := setupMinimalDatabase(tx, execVersion) if err != nil { log.Fatalf("Failed to setup minimal database schema: %v", err) } @@ -134,11 +134,11 @@ func MigrateDatabase(version string) { } dbVersion := getDatabaseVersion(tx) - if dbVersion != version { + if dbVersion != execVersion { log.Fatalf( "Database version '%s' does not match executable version '%s'", dbVersion, - version, + execVersion, ) } |