MCPcopy
hub / github.com/pocketbase/pocketbase / lastAppliedMigrations

Method lastAppliedMigrations

core/migrations_runner.go:292–317  ·  view source on GitHub ↗
(limit int)

Source from the content-addressed store, hash-verified

290}
291
292func (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}

Callers 2

RunMethod · 0.95
DownMethod · 0.95

Calls 3

ItemsMethod · 0.80
SelectMethod · 0.80
DBMethod · 0.65

Tested by

no test coverage detected