Skip to content

Commit e03d678

Browse files
committed
Handle unknown migrations in command_status
1 parent 5136bb3 commit e03d678

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sql-migrate/command_status.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,13 @@ func (c *StatusCommand) Run(args []string) int {
8383
}
8484

8585
for _, r := range records {
86-
rows[r.Id].Migrated = true
87-
rows[r.Id].AppliedAt = r.AppliedAt
86+
status, ok := rows[r.Id]
87+
if !ok {
88+
ui.Warn(fmt.Sprintf("Migration in database %q unknown to sql-migrate; it will not be possible to migrate down this migration", r.Id))
89+
continue
90+
}
91+
status.Migrated = true
92+
status.AppliedAt = r.AppliedAt
8893
}
8994

9095
for _, m := range migrations {

0 commit comments

Comments
 (0)