Generate a Knex schema.createTable() call from an ObjectSchemaBuilder's introspected metadata and DDL extensions.
schema.createTable()
Returns a function that accepts a Knex instance and returns a SchemaBuilder (thenable). Call it inside a migration or setup script:
SchemaBuilder
An ObjectSchemaBuilder with .hasTableName() and column-level DDL extensions (.primaryKey(), .references(), etc.).
ObjectSchemaBuilder
.hasTableName()
.primaryKey()
.references()
(knex: Knex) => Knex.SchemaBuilder — a function that creates the table when executed.
(knex: Knex) => Knex.SchemaBuilder
const createUsersTable = generateCreateTable(UserSchema);await createUsersTable(knex); Copy
const createUsersTable = generateCreateTable(UserSchema);await createUsersTable(knex);
Generate a Knex
schema.createTable()call from an ObjectSchemaBuilder's introspected metadata and DDL extensions.Returns a function that accepts a Knex instance and returns a
SchemaBuilder(thenable). Call it inside a migration or setup script: