Add migrations and continue implementing election insertion

This commit is contained in:
2024-12-30 20:41:28 +01:00
parent 9e96be5ff2
commit 29fb5880e3
9 changed files with 138 additions and 164 deletions

View File

@ -3,10 +3,12 @@
package main
import (
db2 "code.dlmw.ch/dlmw/qv/internal/db"
"code.dlmw.ch/dlmw/qv/internal/models"
"database/sql"
"github.com/go-playground/form/v4"
_ "github.com/mattn/go-sqlite3"
stdlib "github.com/multiprocessio/go-sqlite3-stdlib"
"log/slog"
"net/http"
"os"
@ -22,6 +24,7 @@ type application struct {
var addr = ":8080"
func main() {
stdlib.Register("sqlite_math_functions")
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
db, err := openDb()
@ -30,6 +33,11 @@ func main() {
os.Exit(1)
}
defer db.Close()
err = db2.RunMigrations(db)
if err != nil {
logger.Error(err.Error())
os.Exit(1)
}
formDecoder := form.NewDecoder()