Libraries
    Preparing search index...

    Function generateCreatePolymorphicTables

    • Generate a series of Knex schema.createTable() calls for a polymorphic schema and all its CTI variant tables.

      Returns an array of (knex: Knex) => Knex.SchemaBuilder functions — one for the base table and one for each CTI variant. STI variants add their columns to the base table itself so no extra table is needed.

      Execute them sequentially in a migration:

      Parameters

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

        The base ObjectSchemaBuilder with .withVariants() applied.

      Returns ((knex: Knex) => SchemaBuilder)[]

      An array of table-creation functions to execute in order.

      const creators = generateCreatePolymorphicTables(FileSchema);
      for (const create of creators) {
      await create(knex);
      }