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:
AJ ONeal 2026-06-04 20:19:52 -06:00
parent a408dc890b
commit 3e2b055c88
No known key found for this signature in database

View File

@ -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 {