Member Junction
    Preparing search index...

    Stateless service that coordinates SchemaEngine + RuntimeSchemaManager to create or modify database entities. Both the agent layer and the action layer delegate here.

    Index

    Constructors

    Methods

    • Create or modify multiple entities in a single pipeline batch — one CodeGen run covers all tables, which is the primary performance benefit over calling CreateEntity/ModifyEntity individually.

      Execution sequence:

      1. Sort tables by FK dependency so referenced tables are created first
      2. For each table: normalise FKs + generate migration SQL (CREATE or ALTER)
      3. Run RuntimeSchemaManager.RunPipelineBatch() — one lock, one CodeGen run
      4. Refresh metadata once after all migrations complete
      5. Save provenance (MJ:UDT:Owner, MJ:UDT:Source) for every successful table

      Partial failure is supported: if 3 of 5 tables succeed and 2 fail, the successful tables are live in the DB, CodeGen runs on them, and the caller receives per-table Success flags to present to the user.

      Parameters

      • inputs: BatchTableInput[]

        One entry per table. Tables are sorted internally by FK dependency before migration SQL is generated.

      • contextUser: UserInfo

        MJ context user forwarded to DB queries and provenance.

      • options: PipelineExecutionOptions = {}

        Pipeline execution options applied to the whole batch.

      Returns Promise<BatchPipelineExecutionResult>

    • Load the physical column information for an existing table from MJ's Entity Fields metadata. Returns null if the table is not known to MJ.

      Shared by both the Schema Builder agent (alter path) and the Modify Entity action so there is a single, correct implementation — including Precision and Scale which are required for SchemaEvolution to correctly diff numeric column changes.

      Parameters

      • schemaName: string
      • tableName: string
      • contextUser: UserInfo

      Returns Promise<ExistingTableInfo>

    • Sort table definitions so that tables referenced by FK from other tables in the batch appear BEFORE the tables that reference them.

      Uses Kahn's topological sort algorithm — runs in O(V+E) time where V is the number of tables and E is the number of FK relationships within the batch. Tables with no intra-batch FK dependencies retain their original relative order (stable sort property of Kahn's algorithm with a queue).

      If a circular FK dependency exists (which SchemaEngine would reject during DDL generation anyway), the cycle is detected and the remaining tables are appended in original order so the batch does not silently drop tables.

      Parameters

      Returns TableDefinition[]

      A new array with the same tables in dependency order.