Execute a MigrationDiff directly against a live database without writing a migration file. Intended for db push (dev-only schema sync).
db push
Foreign-key constraint drops are executed as raw ALTER TABLE … DROP CONSTRAINT statements before the main alterTable call.
ALTER TABLE … DROP CONSTRAINT
alterTable
A configured Knex instance or transaction.
The diff from diffSchema.
The table to alter.
const dbState = await introspectDatabase(knex, 'users');const diff = diffSchema(UserSchema, dbState);if (!isDiffEmpty(diff)) await applyDiff(knex, diff, 'users'); Copy
const dbState = await introspectDatabase(knex, 'users');const diff = diffSchema(UserSchema, dbState);if (!isDiffEmpty(diff)) await applyDiff(knex, diff, 'users');
Execute a MigrationDiff directly against a live database without writing a migration file. Intended for
db push(dev-only schema sync).Foreign-key constraint drops are executed as raw
ALTER TABLE … DROP CONSTRAINTstatements before the mainalterTablecall.