Add migration, status and pending checks to database

This commit is contained in:
Michał Gdula 2024-05-06 17:24:24 +01:00
parent b2933a41c1
commit 66fb03fa0d
9 changed files with 146 additions and 42 deletions

View file

@ -2,7 +2,8 @@ package database
import (
"database/sql"
"log"
"fmt"
"os"
"github.com/mattn/go-sqlite3"
)
@ -16,19 +17,22 @@ func Open() {
Conn, err = sql.Open("sqlite3", "tastybites.db?_journal_mode=WAL")
if err != nil {
log.Fatal("Error opening connection: ", err)
fmt.Println("Error opening connection:", err)
os.Exit(1)
}
//Set the connection to use WAL mode
_, err = Conn.Exec("PRAGMA journal_mode=WAL;")
if err != nil {
log.Fatal(err)
fmt.Println(err)
os.Exit(1)
}
}
func Close() {
err := Conn.Close()
if err != nil {
log.Fatal(err)
fmt.Println(err)
os.Exit(1)
}
}