mirror of
https://github.com/therootcompany/golib.git
synced 2026-11-04 06:55:00 +00:00
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:
parent
3e2b055c88
commit
965c233543
@ -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)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user