Skip to main content

SqlScriptMigrationTask

A migration task that runs a raw SQL script against the target database — the resolved form of a *.task.sql file, or an inline object with the same shape.

PropertyTypeRequiredDescription
scriptstring | FunctionyesThe SQL script to execute, or a function that produces it.
titlestringnoHuman-readable title, shown in task-start/task-finish events. Defaults to "Run sql script" when loaded from a *.task.sql file.
filenamestringnoSource file this task was loaded from, if any — set automatically by folder discovery.
import type { SqlScriptMigrationTask } from '@sqb/migrator';

const task: SqlScriptMigrationTask = {
title: 'Create customers table',
script: 'CREATE TABLE customers (id serial primary key, name text not null);',
};

On disk, the same task is a *.task.sql file containing just the raw SQL — see Writing Migration Tasks.