package migrations import ( "log/slog" migrate "github.com/rubenv/sql-migrate" ) //go:generate go-bindata -o ./migrations.bindata.go -pkg migrations -ignore=\\*.go ./... func GetMigrationSource() *migrate.AssetMigrationSource { return &migrate.AssetMigrationSource{ Asset: Asset, AssetDir: AssetDir, Dir: ".", } } func RunMigrations(db migrate.Execer, driver string) (int, error) { source := GetMigrationSource() n, err := migrate.Exec(db, driver, source, migrate.Up) if err != nil { slog.Error("failed to run migrations", "error", err) return 0, err } slog.Info("applied database migrations", "count", n) return n, nil }