Skip to main content

DbMigratorOptions

Options accepted by DbMigrator.execute().

PropertyTypeRequiredDescription
connectionClientConfigurationyesConnection info for the target database. connection.dialect must be 'postgres' — see the warning in Running Migrations.
migrationPackageMigrationPackage | MigrationPackageConfigyesThe migrations to apply.
infoSchemastringnoSchema used for the migrator's bookkeeping tables (migration_summary, migration_events). Defaults to __migration.
scriptVariablesRecord<string, string>noAdditional $(name) substitution variables for .task.sql scripts, merged with the adapter's own defaults (schema, tablespace, owner) and connection.schema.
targetVersionnumbernoMigrate up to (and including) this version. Defaults to the package's highest version.

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,
};

See Running Migrations for usage.