Skip to main content

MigrationConfig

The user-authored form of a single migration — an entry of MigrationPackageConfig.migrations, or the shape of a migration.json/migration.ts manifest file. Resolving it produces a Migration.

PropertyTypeRequiredDescription
versionnumberyesMigration version number. Must be unique within the package; migrations run in ascending order regardless of declaration order.
backupbooleannoWhen true on any migration in the package, DbMigrator.execute() takes a backup (emits backup/calls backupDatabase()) before applying migrations, and restores it (emits restore/calls restoreDatabase()) if execution fails.
tasks(string | MigrationTask | (() => MigrationTask) | (() => Promise<MigrationTask>))[]yesTasks to run for this version — a glob pattern matching *.task.sql/*.task.json files, an inline task object, or a (sync or async) function returning one.
migration.json
{
"version": 13,
"tasks": ["*"]
}

MigrationTask is a union of SqlScriptMigrationTask, InsertDataMigrationTask, and CustomMigrationTask. See Writing Migration Tasks.