update_server/cmd/migrate/main.go
2026-06-10 20:51:17 +03:00

34 lines
630 B
Go

package main
import (
"context"
"fmt"
"os"
"update_server/internal/config"
"update_server/internal/db"
)
func main() {
cfg, err := config.Load()
if err != nil {
exitWithError(err)
}
database, err := db.Open(context.Background(), cfg.SQLitePath)
if err != nil {
exitWithError(err)
}
defer database.Close()
if err := db.Migrate(context.Background(), database, cfg.MigrationsDir); err != nil {
exitWithError(err)
}
fmt.Fprintf(os.Stdout, "migrations applied successfully to %s\n", cfg.SQLitePath)
}
func exitWithError(err error) {
fmt.Fprintf(os.Stderr, "update_server migrate: %v\n", err)
os.Exit(1)
}