Libraries
    Preparing search index...
    • 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:

      Parameters

      • schema: ObjectSchemaBuilder<any, any, any, any, any, any, any>

        An ObjectSchemaBuilder with .hasTableName() and column-level DDL extensions (.primaryKey(), .references(), etc.).

      Returns (knex: Knex) => SchemaBuilder

      (knex: Knex) => Knex.SchemaBuilder — a function that creates the table when executed.

      const createUsersTable = generateCreateTable(UserSchema);
      await createUsersTable(knex);