Revert "serve: run migrations on startup"

This reverts commit 32fea20476.
This commit is contained in:
Tigor Hutasuhut 2024-05-27 14:24:14 +07:00
parent d44185b665
commit b90d5c7601
2 changed files with 0 additions and 28 deletions

View file

@ -28,11 +28,6 @@ var serveCmd = &cobra.Command{
}
defer tele.Close()
if err := db.RunMigrations(cfg); err != nil {
log.New(cmd.Context()).Err(err).Error("failed to run migrations")
os.Exit(1)
}
database, err := db.NewComfy(cfg)
if err != nil {
log.New(cmd.Context()).Err(err).Error("failed to open database")

View file

@ -69,26 +69,3 @@ func ApplyLogger(cfg *config.Config, db *sql.DB) *sql.DB {
sqldblogger.WithSQLQueryAsMessage(true),
)
}
func RunMigrations(cfg *config.Config) error {
if cfg.Bool("db.automigrate") {
driver := cfg.String("db.driver")
dsn := cfg.String("db.string")
db, err := sql.Open(driver, dsn)
if err != nil {
return errs.Wrapw(err, "migration: failed to open database", "driver", driver, "db.string", dsn)
}
defer db.Close()
goose.SetLogger(goose.NopLogger())
goose.SetBaseFS(Migrations)
if err := goose.SetDialect(driver); err != nil {
return errs.Wrapw(err, "failed to set goose dialect", "dialect", driver, "dsn", dsn)
}
if err := goose.Up(db, "db/migrations"); err != nil {
return errs.Wrapw(err, "failed to migrate database", "dialect", driver, "dsn", dsn)
}
}
return nil
}