Skip to main content

Processing Database Migrations

Processing database migrations is done using the ductape.processor.db.migration interface.

This interface provides two methods for managing migrations:

  • run — Executes the specified database migration.
  • rollback — Rolls back (reverts) the specified migration.
await ductape.processor.db.migration.run({
migration: string,
env: string,
product: string
})

await ductape.processor.db.migration.rollback({
migration: string,
env: string,
product: string
})

Parameters

Both run and rollback methods accept the same input object:

FieldTypeRequiredDescription
migrationstringYesThe full migration tag in the format "database_tag:action_tag".
envstringYesEnvironment slug (e.g. "dev", "prd").
productstringYesProduct tag the migration belongs to.

Note: The migration tag should follow the format database_tag:action_tag, where:

  • database_tag identifies the database the migration belongs to
  • action_tag is the specific migration action to run

Returns

A Promise<unknown> — resolves with the result of the migration execution. The structure of the result depends on the logic defined within the migration itself.

Example

Run a Migration

await ductape.processor.db.migration.run({
migration: 'postgres-db:create_users_table',
env: 'dev',
product: 'my-product'
});

Rollback a Migration

await ductape.processor.db.migration.rollback({
migration: 'postgres-db:create_users_table',
env: 'dev',
product: 'my-product'
});

See Also