From b8bb5e8d7209dd711e5299e529fedec9410edc49 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Tue, 27 Jun 2023 00:33:31 +0300 Subject: [PATCH] fixed migrate down not returning the correct migrations order when the stored applied time is in seconds --- tools/migrate/runner.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/migrate/runner.go b/tools/migrate/runner.go index 952b7ee0..0e23c191 100644 --- a/tools/migrate/runner.go +++ b/tools/migrate/runner.go @@ -246,7 +246,9 @@ func (r *Runner) lastAppliedMigrations(limit int) ([]string, error) { err := r.db.Select("file"). From(r.tableName). 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)). Column(&files)