From 965c2335439f197133e474407ed49d638a59a667 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 5 Jun 2026 01:54:16 -0600 Subject: [PATCH] fix(sql-migrate): always run init migration in sync sync now runs the actual init migration file from disk before reloading the migrations log. The init migration uses CREATE TABLE IF NOT EXISTS and || true to handle idempotency across all supported SQL backends. --- cmd/sql-migrate/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/sql-migrate/main.go b/cmd/sql-migrate/main.go index 934c6b1..0e536fb 100644 --- a/cmd/sql-migrate/main.go +++ b/cmd/sql-migrate/main.go @@ -986,8 +986,13 @@ func syncLog(runner *shmigrate.Migrator) { fmt.Printf(shmigrate.ShHeader) fmt.Println("") + fmt.Println("# SYNC: run initial migration (idempotent)") + initPath := filepath.Join(runner.MigrationsDir, M_MIGRATOR_UP_NAME) + initCmd := strings.Replace(runner.SqlCommand, "%s", filepathUnclean(initPath), 1) + fmt.Printf("%s || true\n", initCmd) + fmt.Println("") fmt.Println("# SYNC: reload migrations log from DB") - fmt.Printf("%s > %s || true\n", syncCmd, logPath) + fmt.Printf("%s > %s\n", syncCmd, logPath) fmt.Printf("cat %s\n", logPath) }