Compare a code-first schema model against a live database table state and produce a diff describing the changes needed to bring the database in sync.
The code-first ObjectSchemaBuilder.
ObjectSchemaBuilder
The current database state from introspectDatabase.
A MigrationDiff describing columns, indexes, and foreign keys to add, drop, or alter.
const dbState = await introspectDatabase(knex, 'users');const diff = diffSchema(UserSchema, dbState);if (diff.addColumns.length > 0) { const migration = generateMigration(diff, 'users'); console.log(migration.up);} Copy
const dbState = await introspectDatabase(knex, 'users');const diff = diffSchema(UserSchema, dbState);if (diff.addColumns.length > 0) { const migration = generateMigration(diff, 'users'); console.log(migration.up);}
Compare a code-first schema model against a live database table state and produce a diff describing the changes needed to bring the database in sync.