// Entry point for applying database migrations for flux-feed application package main import ( "database/sql" "log" "git.runcible.io/androiddrew/flux-feed/config" "github.com/golang-migrate/migrate/v4" "github.com/golang-migrate/migrate/v4/database/sqlite3" _ "github.com/golang-migrate/migrate/v4/source/file" _ "github.com/mattn/go-sqlite3" ) func main() { cfg := config.New() db, err := sql.Open(cfg.DatabaseDriver, cfg.DatabaseDSN) defer db.Close() err = db.Ping() if err != nil { log.Fatal(err) } log.Printf("Connected to Database: %s", cfg.DatabaseDSN) driver, err := sqlite3.WithInstance(db, &sqlite3.Config{}) log.Printf("Using migrations path: %s", cfg.MigrationsPath) m, err := migrate.NewWithDatabaseInstance( cfg.MigrationsPath, cfg.DatabaseDriver, driver) if err != nil { log.Fatal(err) } log.Printf("Migrating: %s", cfg.DatabaseDSN) err = m.Up() if err != nil { log.Fatal(err) } }