Skip to content

Migrator

getAvailableMigrations()

getAvailableMigrations() — returns array

Available in: migrator Category: General Functions

Searches db/migrate folder for migrations. Whilst you can use this in your application, the recommended usage is via either the CLI or the provided GUI interface

$getVersionsPreviouslyMigrated). Callers that already hold the list (doctor, info, migrateTo) pass it through to avoid re-running the tracking-table probe chain; when empty it is computed here.

NameTypeRequiredDefaultDescription
pathstringno[runtime expression]Path to Migration Files: defaults to /app/migrator/migrations/
previousMigrationListstringno—Optional precomputed applied-versions list (from
// 1. Get all available migrations and find the latest version
migrations = application.wheels.migrator.getAvailableMigrations();

if (arrayLen(migrations)) {
    latestVersion = migrations[arrayLen(migrations)].version;
} else {
    latestVersion = 0;
}

// 2. List pending (not yet run) migrations
migrations = application.wheels.migrator.getAvailableMigrations();

for (migration in migrations) {
    if (migration.status != "migrated") {
        writeOutput(migration.version & " - " & migration.name);
    }
}

// 3. Use a custom migrations path
migrations = application.wheels.migrator.getAvailableMigrations(path=expandPath("/app/db/migrate/"));