DbMigratorOptions
Options accepted by DbMigrator.execute().
| Property | Type | Required | Description |
|---|---|---|---|
connection | ClientConfiguration | yes | Connection info for the target database. connection.dialect (required) selects the migration adapter — 'postgres', 'oracle', 'mysql', 'mariadb', 'mssql', or 'sqlite'; for SQLite, connection.driver ('sqlite' or 'sqljs') picks between the two SQLite adapters. |
migrationPackage | MigrationPackage | MigrationPackageConfig | yes | The migrations to apply. |
infoSchema | string | no | Schema the migrator's bookkeeping tables (migration_summary, migration_events) live under — or, for dialects with no real schema concept (Oracle, SQLite), a table-name prefix. Defaults to __migration. |
scriptVariables | Record<string, string> | no | Additional $(name) substitution variables for .task.sql scripts, merged with the adapter's own dialect-specific defaults (schema, tablespace, owner) and connection.schema. |
targetVersion | number | no | Migrate up to (and including) this version. Defaults to the package's highest version. |
transaction | 'run' | 'migration' | 'none' | no | How the run is wrapped in transactions: one for the whole run, one per migration, or none (the default). Only the PostgreSQL, sqlite and sqljs adapters support 'run'/'migration'; the others throw a TypeError. Since v6.3.0. |
dryRun | boolean | no | Runs every pending migration in one transaction, emits the same events, then rolls back instead of committing. Implies transaction: 'run'; any other transaction mode is refused. Since v6.3.0. |
ClientConfiguration is defined by @sqb/connect — see its
interface reference.
import type { DbMigratorOptions } from '@sqb/migrator';
const options: DbMigratorOptions = {
connection: { dialect: 'postgres', database: 'my_database' },
migrationPackage: { name: 'my-app', migrations: ['migrations/**/*'] },
targetVersion: 14,
};
MigrationTransactionMode ('run' | 'migration' | 'none') is exported as a type for the
transaction option. See Running Migrations for usage,
and Transactional runs and dry runs
for the semantics.