Class DatabaseSchemaCreator
Creates the initial database schema during install.
Inheritance
System.Object
Namespace: Umbraco.Cms.Infrastructure.Migrations.Install
Assembly: Umbraco.Infrastructure.dll
Syntax
public class DatabaseSchemaCreator
Constructors
View SourceDatabaseSchemaCreator(IUmbracoDatabase, ILogger<DatabaseSchemaCreator>, ILoggerFactory, IUmbracoVersion, IEventAggregator, IOptionsMonitor<InstallDefaultDataSettings>)
Declaration
public DatabaseSchemaCreator(IUmbracoDatabase database, ILogger<DatabaseSchemaCreator> logger, ILoggerFactory loggerFactory, IUmbracoVersion umbracoVersion, IEventAggregator eventAggregator, IOptionsMonitor<InstallDefaultDataSettings> defaultDataCreationSettings)
Parameters
Type | Name | Description |
---|---|---|
IUmbraco |
database | |
ILogger<Database |
logger | |
ILogger |
loggerFactory | |
IUmbraco |
umbracoVersion | |
IEvent |
eventAggregator | |
IOptions |
defaultDataCreationSettings |
Methods
View SourceDropTable(String)
Drops the table for the specified tableName
Declaration
public void DropTable(string tableName)
Parameters
Type | Name | Description |
---|---|---|
System. |
tableName |
InitializeDatabaseSchema()
Initializes the database by creating the umbraco db schema.
Declaration
public void InitializeDatabaseSchema()
Remarks
This needs to execute as part of a transaction.
TableExists(String)
Returns whether a table with the specified tableName
exists in the database.
Declaration
public bool TableExists(string tableName)
Parameters
Type | Name | Description |
---|---|---|
System. |
tableName | The name of the table. |
Returns
Type | Description |
---|---|
System. |
|
Examples
if (schemaHelper.TableExist("MyTable"))
{
// do something when the table exists
}
View Source
TableExists<T>()
Returns whether the table for the specified T
exists in the database.
Declaration
public bool TableExists<T>()
Returns
Type | Description |
---|---|
System. |
|
Type Parameters
Name | Description |
---|---|
T | The type representing the DTO/table. |
Remarks
If T
has been decorated with an T
will be used instead.
Examples
if (schemaHelper.TableExist<MyDto>)
{
// do something when the table exists
}