mirror of
https://github.com/therootcompany/golib.git
synced 2026-07-10 15:20:21 +00:00
fix(sql-migrate): strip id\t prefix when parsing migrations.log
parseAndFixupBatches treated every line as a migration name, but the new log format uses id\tname (tab-separated). This caused fixupMigration to look for non-existent files like '05aba66a\t2026-06-03-003000_team-create.up.sql'. Align with shmigrate.Applied() which already handles both formats.
This commit is contained in:
parent
a408dc890b
commit
3e2b055c88
@ -749,8 +749,20 @@ func (state *State) parseAndFixupBatches(text string) error {
|
||||
state.Lines = strings.Split(text, "\n")
|
||||
for i := range state.Lines {
|
||||
line := strings.TrimSpace(state.Lines[i])
|
||||
migration := commentStartRe.ReplaceAllString(line, "")
|
||||
migration := line
|
||||
// strip comments (before tab-split so trailing comments on data lines are handled)
|
||||
migration = commentStartRe.ReplaceAllString(migration, "")
|
||||
migration = strings.TrimSpace(migration)
|
||||
// strip leading id\t prefix from new log format (id<tab>name)
|
||||
// ignore any additional tab-delimited fields for future-proofing
|
||||
parts := strings.Split(migration, "\t")
|
||||
if len(parts) >= 2 {
|
||||
migration = parts[1]
|
||||
} else if len(parts) == 1 {
|
||||
migration = parts[0]
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
if migration != "" {
|
||||
up, down, warn, err := fixupMigration(state.MigrationsDir, migration)
|
||||
if warn != nil {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user