phoneassistant/database/migrate.go
Elizabeth Hunt 18a945aab9
Some checks failed
continuous-integration/drone/push Build is failing
initial commit by simponic-infra
2025-01-12 23:09:34 -08:00

40 lines
589 B
Go

package database
import (
"log"
"database/sql"
_ "github.com/mattn/go-sqlite3"
)
type Migrator func(*sql.DB) (*sql.DB, error)
func DoNothing(dbConn *sql.DB) (*sql.DB, error) {
log.Println("doing nothing")
_, err := dbConn.Exec(`SELECT 0;`)
if err != nil {
return dbConn, err
}
return dbConn, nil
}
func Migrate(dbConn *sql.DB) (*sql.DB, error) {
log.Println("migrating database")
migrations := []Migrator{
DoNothing,
}
for _, migration := range migrations {
dbConn, err := migration(dbConn)
if err != nil {
return dbConn, err
}
}
return dbConn, nil
}