fixed migrate down not returning the correct migrations order when the stored applied time is in seconds
This commit is contained in:
@@ -246,7 +246,9 @@ func (r *Runner) lastAppliedMigrations(limit int) ([]string, error) {
|
|||||||
err := r.db.Select("file").
|
err := r.db.Select("file").
|
||||||
From(r.tableName).
|
From(r.tableName).
|
||||||
Where(dbx.Not(dbx.HashExp{"applied": nil})).
|
Where(dbx.Not(dbx.HashExp{"applied": nil})).
|
||||||
OrderBy("applied DESC", "file DESC").
|
// unify microseconds and seconds applied time for backward compatibility
|
||||||
|
OrderBy("substr(applied||'0000000000000000', 0, 17) DESC").
|
||||||
|
AndOrderBy("file DESC").
|
||||||
Limit(int64(limit)).
|
Limit(int64(limit)).
|
||||||
Column(&files)
|
Column(&files)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user