package main import ( "context" "log/slog" "os" "time" "git.amiirkhl.ir/starcoach-hackathon/zarinpal-analytics-backend/internal/config" "git.amiirkhl.ir/starcoach-hackathon/zarinpal-analytics-backend/internal/database" ) func main() { logger := slog.New(slog.NewJSONHandler(os.Stdout, nil)) cfg, err := config.Load() if err != nil { logger.Error("configuration failed", "error", err) os.Exit(1) } ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() pool, err := database.Open(ctx, cfg.DatabaseURL) if err != nil { logger.Error("database connection failed", "error", err) os.Exit(1) } defer pool.Close() migration, err := os.ReadFile("migrations/000001_mvp.sql") if err != nil { logger.Error("reading migration failed", "error", err) os.Exit(1) } if err := database.Migrate(ctx, pool, string(migration)); err != nil { logger.Error("migration failed", "error", err) os.Exit(1) } logger.Info("migration complete", "version", 1) }