TDatabaseManager Class
Manages the database schema lifecycle: creates, updates, validates, and destroys the database schema based on the Aurelius ORM mapping model.
Remarks
TDatabaseManager compares the schema currently present in the database (imported via an ISchemaImporter) with the schema derived from the mapped entity classes and produces a set of DDL commands to synchronize the two.
The typical usage pattern is: - Call UpdateDatabase to automatically detect and apply required changes.
- Call ValidateDatabase to inspect differences without applying them.
- Call BuildDatabase to create the schema on an empty database.
- Call DestroyDatabase to drop all mapped schema objects.
After any of these operations, the Actions, Warnings, and Errors collections provide a human-readable report of what occurred or what requires manual intervention.
Use the AllowDestructiveCommands property to permit DROP TABLE and DROP SEQUENCE statements during an update. Use UseTransactions to control whether DDL is wrapped in a transaction.
Syntax
Unit: Aurelius.Engine.DatabaseManager
TDatabaseManager = class(TAbstractManager);
Constructors
| Name | Description |
|---|---|
| Create | Overloaded Create(IDBConnection, TMappingExplorer) Create(IDBConnection, TArray<TMappingExplorer>) |
Methods
| Name | Description |
|---|---|
| BuildDatabase | Creates the database schema from scratch based on the mapping model. |
| DestroyDatabase | Drops all mapped schema objects from the database. |
| Update | Overloaded Update(IDBConnection) Update(IDBConnection, TMappingExplorer) Update(IDBConnection, TArray<TMappingExplorer>) |
| UpdateDatabase | Validates the database schema and executes the DDL statements required to bring it in line with the mapping model. |
| ValidateDatabase | Compares the live database schema against the mapping model and records differences as actions, warnings, and errors without executing any DDL. |
Properties
| Name | Description |
|---|---|
| ActionCount | Gets the number of actions recorded by the last schema operation. |
| Actions | Gets the collection of informational actions recorded by the last schema operation. |
| AllowDestructive​Commands | Indicates whether destructive DDL commands (DROP TABLE, DROP SEQUENCE) are permitted during UpdateDatabase and DestroyDatabase. |
| Commands | Gets the ordered list of DDL commands to be executed against the database. |
| ErrorCount | Gets the number of errors recorded by the last schema operation. |
| Errors | Gets the collection of errors recorded by the last schema operation. |
| ExistingDB | Gets the metadata snapshot of the database schema as it exists in the database. |
| IgnoreConstraintName | Indicates whether constraint names are ignored when comparing schema objects. |
| Importer | Gets the schema importer used to read the current database metadata. |
| SQLExecutionEnabled | Indicates whether DDL statements generated by schema operations are actually executed against the database. |
| SQLStatements | Gets the SQL DDL statements that were generated by the last schema operation. |
| TargetDB | Gets the metadata snapshot of the target database schema derived from the mapping model. |
| UseTransactions | Indicates whether schema operations are wrapped in a database transaction. |
| WarningCount | Gets the number of warnings recorded by the last schema operation. |
| Warnings | Gets the collection of warnings recorded by the last schema operation. |