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.
This commit is contained in:
AJ ONeal 2026-06-05 01:54:16 -06:00
parent 3e2b055c88
commit 965c233543
No known key found for this signature in database

View File

@ -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)
}