From e5d57f2c4a9f01ac7a2b11c04b932311bd240611 Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 9 May 2024 21:59:01 +0200 Subject: model: Migrate only in empty databases --- model/database.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/model/database.go b/model/database.go index cdded4a..8e002d6 100644 --- a/model/database.go +++ b/model/database.go @@ -101,16 +101,18 @@ func MigrateDatabase(version string) { if err != nil { log.Fatalf("Failed to setup minimal database schema: %v", err) } - } - query, err := GetSql(`migrate`) - if err != nil { - log.Fatal(err) - } - _, err = tx.Exec(query) - if err != nil { - return err + log.Println("Executing initial migration") + query, err := GetSql(`migrate`) + if err != nil { + log.Fatal(err) + } + _, err = tx.Exec(query) + if err != nil { + return err + } } + return nil }) if err != nil { -- cgit v1.2.3-70-g09d2