CustomMigrationTask
A migration task that runs an arbitrary function instead of a SQL script or row insert — for
anything a .task.sql/.task.json file can't express.
| Property | Type | Required | Description |
|---|---|---|---|
fn | (connection: any, adapter: MigrationAdapter) => void | Promise<void> | yes | Function invoked with the active database connection and the current MigrationAdapter. |
title | string | no | Human-readable title. Defaults to "Run custom function" when loaded from a manifest file. |
filename | string | no | Source file this task was loaded from, if any. |
import type { CustomMigrationTask } from '@sqb/migrator';
const task: CustomMigrationTask = {
title: 'Backfill full-text search index',
fn: async connection => {
await connection.execute('REINDEX INDEX customers_search_idx');
},
};
See Writing Migration Tasks for how a
.task.ts/.task.js file resolves to this shape.