Member Junction
    Preparing search index...

    Singleton pipeline orchestrator for runtime schema changes.

    Usage: const rsm = RuntimeSchemaManager.Instance; if (!rsm.IsEnabled) throw new Error('RSU is disabled'); const result = await rsm.RunPipeline(input);

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get GlobalKey(): string

      Returns string

    Methods

    • Returns the complete set of schema names this instance will block in DDL.

      Always includes __mj (the MemberJunction system schema, never modifiable). Also includes any additional schemas configured via the RSU_PROTECTED_SCHEMAS environment variable (comma-separated list, e.g. RSU_PROTECTED_SCHEMAS=dbo,sys).

      Callers such as the Database Designer Validator use this for early-exit UX feedback before DDL is even generated — the same set that ValidateMigrationSQL() enforces at the SQL level.

      Returns ReadonlySet<string>

      A readonly lowercase set of all protected schema names.

    • The Global Object Store is a place to store global objects that need to be shared across the application. Depending on the execution environment, this could be the window object in a browser, or the global object in a node environment, or something else in other contexts. The key here is that in some cases static variables are not truly shared because it is possible that a given class might have copies of its code in multiple paths in a deployed application. This approach ensures that no matter how many code copies might exist, there is only one instance of the object in question by using the Global Object Store.

      Returns GlobalObjectStore

    • Execute the RSU pipeline for a batch of inputs.

      Correctness guarantee: migrations and CodeGen never overlap. All migrations execute under one lock, then CodeGen runs once against the fully-committed schema.

      Flow:

      1. Validate all inputs (fail fast — reject entire batch on validation error)
      2. Lock
      3. For each input: write migration file → execute SQL (independent success/failure)
      4. Unlock
      5. ONE CodeGen run (covers all successful migrations)
      6. ONE compile
      7. ONE restart
      8. ONE git commit (all migration files)
      9. Resolve each caller with per-item migration result + shared post-migration result

      Parameters

      Returns Promise<RSUPipelineBatchResult>

    • Run the RSU pipeline with automatic retry for transient failures. Only retries steps that are known to be transient (SQL execution, CodeGen, compilation, restart). Validation and git steps are not retried.

      Parameters

      • input: RSUPipelineInput

        Pipeline input

      • maxRetries: number = 2

        Maximum number of retries (default: 2, so 3 total attempts)

      • baseDelayMs: number = 5000

        Base delay for exponential backoff (default: 5000ms)

      Returns Promise<RSUPipelineResult>

    • Set the additionalSchemaInfo file path that CodeGen reads (from mj.config.cjs additionalSchemaInfo). RSU writes its soft PK/FK config to THIS path so the subsequent CodeGen run actually finds it. Injected by the server at startup, mirroring SetCodeGenOutputPaths.

      Without injection, RSU falls back to RSU_ADDITIONAL_SCHEMA_INFO_PATH / 'additionalSchemaInfo.json' — a path that need not match CodeGen's configured one. When they diverge, RSU writes soft PKs to a file CodeGen never reads, and every integration table is skipped with "No primary key found". Keeping the two in lockstep is the whole point of this setter.

      Parameters

      • configuredPath: string

      Returns void

    • Set the CodeGen output directory paths (from mj.config.cjs output[].directory). Used by the git step to stage only CodeGen-produced source files.

      Parameters

      • paths: string[]

      Returns void

    • Returns the singleton instance of the class. If the instance does not exist, it is created and stored in the Global Object Store. If className is provided it will be used as part of the key in the Global Object Store, otherwise the actual class name will be used. NOTE: the class name used by default is the lowest level of the object hierarchy, so if you have a class that extends another class, the lowest level class name will be used.

      Type Parameters

      Parameters

      • this: new () => T
      • OptionalclassName: string

      Returns T