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 }