Protected _sqlPrivate Static _generatedPrivate Static _modifiedPrivate Static _newStatic generatedGlobally scoped list of validators that have been generated during the metadata management process.
Static modifiedGlobally scoped list of entities that have been modified during the metadata management process.
Static newGlobally scoped list of entities that have been created during the metadata management process.
Private LogSQLAndExecutes the given SQL query using the given ConnectionPool object. If the appendToLogFile parameter is true, the query will also be appended to the log file. Note that in order to append to the log file, ManageMetadataBase.manageMetaDataLogging must be called first.
The ConnectionPool object to use to execute the query.
The SQL query to execute.
Optional description: stringA description of the query to append to the log file.
if set to true tells the logger that the provided SQL represents a recurring script meaning it is something that is executed, generally, for all CodeGen runs. In these cases, the Config settings can result in omitting these recurring scripts from being logged because the configuration environment may have those recurring scripts already set to run after all run-specific migrations get run.
Protected applicationProtected applyApply Advanced Generation features - Smart Field Identification and Form Layout Generation
Protected applyApply form layout generation results to set category on entity fields
Database connection pool
Entity ID to update
Entity fields
Form layout result from LLM
If true, apply entityImportance; if false, skip it
Protected applyProtected checkThis method will look for situations where entity metadata exist in the entities metadata table but the underlying table has been deleted. In this case, the metadata for the entity should be removed. This method is called as part of the manageMetadata method and is not intended to be called directly.
Protected checkProtected createCreates the default constraint for a special date field. This method is called as part of the ensureSpecialDateFieldExistsAndHasCorrectDefaultValue method and is not intended to be called directly.
Protected createProtected createCreates a new application using the entity framework. This ensures the server-side entity extension is used, which handles:
SQL connection pool (unused but kept for signature compatibility)
Pre-generated UUID for the application
Name of the application
Schema name for SchemaAutoAddNewEntities
Current user for entity operations
The application ID if successful, null otherwise
Protected createProtected createProtected createProtected createProtected createProtected createProtected createProtected deleteProtected dropDrops and recreates the default constraint for a special date field. This method is called as part of the ensureSpecialDateFieldExistsAndHasCorrectDefaultValue method and is not intended to be called directly.
Protected dropProtected ensureThis method ensures that the __mj_CreatedAt and __mj_UpdatedAt fields exist in each entity that has TrackRecordChanges set to true. If the fields do not exist, they are created. If the fields exist but have incorrect default values, the default values are updated. The default value that is to be used for these special fields is GETUTCDATE() which is the UTC date and time. This method is called as part of the manageEntityFields method and is not intended to be called directly.
Protected ensureProtected ensureThis method handles the validation of the existence of the specified special date field and if it does exist it makes sure the default value is set correctly, if it doesn't exist it makes sure that it is created. This method is called as part of the ensureCreatedAtUpdatedAtFieldsExist method and is not intended to be called directly.
Protected generateThis method generates descriptions for entities in teh system where there is no existing description. This is an experimental feature and is done using AI. In order for it to be invoked, the EntityDescriptions feature must be enabled in the Advanced Generation configuration.
Protected generateGenerates a TypeScript field validator function from the text of a SQL CHECK constraint.
the data object containing the entity name, column name, and constraint definition
all of the entity fields in the system
the current user
a flag indicating whether or not to generate new code, this is set to false when we are just loading the generated code from the database.
a data structure with the function text, function name, function description, and a success flag
Protected getProtected getProtected getProtected getCreates a SQL statement to retrieve all of the pending entity fields that need to be created in the metadata. This method looks for fields that exist in the underlying database but are NOT in the metadata.
IMPORTANT: The sequence calculation uses a dynamic offset based on the maximum existing sequence for each entity, plus 100,000, plus the column sequence. This ensures no collision with existing sequences while maintaining deterministic ordering. The spUpdateExistingEntityFieldsFromSchema stored procedure runs AFTER this method and will correct the sequences to ensure they are in the correct sequential order starting from 1. In a migration, the spUpdateExistingEntityFieldsFromSchema runs afterwards as well so this behavior ensures CodeGen works consistently.
Protected isThis method will load all generated code from the database - this is intended to be used when you are bypassing managing the metadata.
Protected manageManages the creation, updating and deletion of entity field records in the metadata based on the database schema.
Protected manageThis method creates and updates relationships in the metadata based on foreign key relationships in the database.
specify any schemas to exclude here and any relationships to/from the specified schemas will be ignored
Protected manageManages M->M relationships between entities in the metadata based on foreign key relationships in the database. NOT IMPLEMENTED IN CURRENT VERSION IN BASE CLASS. M->M relationships ARE supported fully, but they are not AUTO generated by this method, instead an administrator must manually create these relationships in the metadata.
Primary function to manage metadata within the CodeGen system. This function will call a series of sub-functions to manage the metadata.
the ConnectionPool object to use for querying and updating the database
Protected manageManages 1->M relationships between entities in the metadata based on foreign key relationships in the database.
specify any schemas to exclude here and any relationships to/from the specified schemas will be ignored
Protected manageProtected manageProtected manageProtected markupProtected newProtected parseProtected parseThis method takes the stored DEFAULT CONSTRAINT value from the database and parses it to retrieve the actual default value. This is necessary because the default value is sometimes wrapped in parentheses and sometimes wrapped in single quotes. This method removes the wrapping characters and returns the actual default value. Some common raw values that exist in SQL Server include 'getdate()', '(getdate())', 'N''SomeValue''', etc. and this method will remove those wrapping characters to get the actual underlying default value. NOTE: For future versions of MemberJunction where multiple back-end providers could be used, this method will be moved to the Provider architecture so that database-specific versions can be implemented, along with many other aspects of this current codebase.
Protected processProcess entities in batches with parallel execution
Database connection pool
Entities to process
All fields for all entities (will be filtered per entity)
AdvancedGeneration instance
User context
Number of entities to process in parallel (default 5)
Protected processProcess advanced generation for a single entity
Database connection pool
Entity to process
All fields for all entities (will be filtered for this entity)
AdvancedGeneration instance
User context
Private runProtected setThis method updates the DefaultColumnWidth field in the EntityField metadata. The default logic uses a stored procedure called spSetDefaultColumnWidthWhereNeeded which is part of the MJ Core Schema. You can override this method to implement custom logic for setting default column widths. It is NOT recommended to modify the stored procedure in the MJ Core Schema because your changes will be overriden during a future upgrade.
Protected shouldProtected simpleProtected syncProtected updateThis method is responsible for generating a Display Name for each field where a display name is not already set. The approach in the base class uses a simple algorithm that looks for case changes in the field name and inserts spaces at those points. It also strips the trailing 'ID' from the field name if it exists. Override this method in a sub-class if you would like to implement a different approach for generating display names.
This method handles updating entity field related name field maps which is basically the process of finding the related entity field that is the "name" field for the related entity.
Protected updateProtected updateProtected updateSyncs SchemaInfo records from database schemas, capturing extended properties as descriptions. Creates new SchemaInfo records for schemas that don't exist yet and updates descriptions from schema extended properties for existing records.
SQL connection pool
Array of schema names to exclude from processing
Promise
Protected Static add
Base class for managing metadata within the CodeGen system. This class can be sub-classed to extend/override base class functionality. Make sure to use the RegisterClass decorator from the @memberjunction/global package to properly register your subclass with a priority of 1+ to ensure it gets instantiated.