Migrator
getAvailableMigrations()
Signature
Section titled “Signature”getAvailableMigrations() — returns array
Available in: migrator
Category: General Functions
Description
Section titled “Description”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.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
path | string | no | [runtime expression] | Path to Migration Files: defaults to /app/migrator/migrations/ |
previousMigrationList | string | no | — | Optional precomputed applied-versions list (from |
Examples
Section titled “Examples”// 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/"));