| 290 | } |
| 291 | |
| 292 | func (r *MigrationsRunner) lastAppliedMigrations(limit int) ([]string, error) { |
| 293 | var files = make([]string, 0, limit) |
| 294 | |
| 295 | loadedMigrations := r.migrationsList.Items() |
| 296 | |
| 297 | names := make([]any, len(loadedMigrations)) |
| 298 | for i, migration := range loadedMigrations { |
| 299 | names[i] = migration.File |
| 300 | } |
| 301 | |
| 302 | err := r.app.DB().Select("file"). |
| 303 | From(r.tableName). |
| 304 | Where(dbx.Not(dbx.HashExp{"applied": nil})). |
| 305 | AndWhere(dbx.HashExp{"file": names}). |
| 306 | // unify microseconds and seconds applied time for backward compatibility |
| 307 | OrderBy("substr(applied||'0000000000000000', 0, 17) DESC"). |
| 308 | AndOrderBy("file DESC"). |
| 309 | Limit(int64(limit)). |
| 310 | Column(&files) |
| 311 | |
| 312 | if err != nil { |
| 313 | return nil, err |
| 314 | } |
| 315 | |
| 316 | return files, nil |
| 317 | } |