summaryrefslogtreecommitdiff
path: root/model/database.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/database.go')
-rw-r--r--model/database.go21
1 files changed, 3 insertions, 18 deletions
diff --git a/model/database.go b/model/database.go
index f5fd67a..4740899 100644
--- a/model/database.go
+++ b/model/database.go
@@ -2,26 +2,15 @@ package model
import (
"database/sql"
- "embed"
"log"
_ "github.com/mattn/go-sqlite3"
+
+ "xengineering.eu/ceres/model/migrations"
)
var db *sql.DB
-//go:embed sql/*.sql
-var sqlCode embed.FS
-
-func GetSql(code string) (string, error) {
- query, err := sqlCode.ReadFile("sql/" + code + ".sql")
- if err != nil {
- return "", err
- }
-
- return string(query), nil
-}
-
func ConnectDatabase(path string) {
var err error
@@ -123,11 +112,7 @@ func MigrateDatabase(execVersion string) {
}
log.Println("Executing initial migration")
- query, err := GetSql(`migrate`)
- if err != nil {
- log.Fatal(err)
- }
- _, err = tx.Exec(query)
+ err = migrations.Migration001(tx)
if err != nil {
return err
}