Skip to content

Function: runMigrations()

runMigrations<S>(options): Promise<MigrationResult>

Defined in: server/src/migrations.ts:326

Deploy-time migration runner. Diffs the declared schema against the live database, adds any new columns, and regenerates every trigger so added / removed user-table columns land in the change log payload.

v0.1 posture:

  • New columns are added automatically via ALTER TABLE ADD COLUMN.
  • Dropped or type-changed columns are refused — throws MigrationRefused before touching the database.
  • Every trigger is dropped and recreated on each run. Cheap for D1 because the batch size scales with tables × 3, not with change log size; explicit regeneration also self-heals against missing triggers from a partial past run.

ensureSchema() is kept for initial-boot idempotency; production deploys should call runMigrations() after the schema changes.

S extends Record<string, AnyTable>

RunMigrationsOptions<S>

Promise<MigrationResult>