Class DatabaseBuilder
Supports building and configuring the database.
Inheritance
Namespace: Umbraco.Cms.Infrastructure.Migrations.Install
Assembly: Umbraco.Infrastructure.dll
Syntax
public class DatabaseBuilder
Constructors
View SourceDatabaseBuilder(ICoreScopeProvider, IScopeAccessor, IUmbracoDatabaseFactory, IRuntimeState, ILoggerFactory, IKeyValueService, IDbProviderFactoryCreator, IConfigManipulator, IOptionsMonitor<GlobalSettings>, IOptionsMonitor<ConnectionStrings>, IMigrationPlanExecutor, DatabaseSchemaCreatorFactory, IEnumerable<IDatabaseProviderMetadata>)
Initializes a new instance of the DatabaseBuilder class.
Declaration
public DatabaseBuilder(ICoreScopeProvider scopeProvider, IScopeAccessor scopeAccessor, IUmbracoDatabaseFactory databaseFactory, IRuntimeState runtimeState, ILoggerFactory loggerFactory, IKeyValueService keyValueService, IDbProviderFactoryCreator dbProviderFactoryCreator, IConfigManipulator configManipulator, IOptionsMonitor<GlobalSettings> globalSettings, IOptionsMonitor<ConnectionStrings> connectionStrings, IMigrationPlanExecutor migrationPlanExecutor, DatabaseSchemaCreatorFactory databaseSchemaCreatorFactory, IEnumerable<IDatabaseProviderMetadata> databaseProviderMetadata)
Parameters
Type | Name | Description |
---|---|---|
ICoreScopeProvider | scopeProvider | |
IScopeAccessor | scopeAccessor | |
IUmbracoDatabaseFactory | databaseFactory | |
IRuntimeState | runtimeState | |
ILoggerFactory | loggerFactory | |
IKeyValueService | keyValueService | |
IDbProviderFactoryCreator | dbProviderFactoryCreator | |
IConfigManipulator | configManipulator | |
IOptionsMonitor<GlobalSettings> | globalSettings | |
IOptionsMonitor<ConnectionStrings> | connectionStrings | |
IMigrationPlanExecutor | migrationPlanExecutor | |
DatabaseSchemaCreatorFactory | databaseSchemaCreatorFactory | |
IEnumerable<IDatabaseProviderMetadata> | databaseProviderMetadata |
Properties
View SourceCanConnectToDatabase
Gets a value indicating whether it is possible to connect to the configured database. It does not necessarily mean that Umbraco is installed, nor up-to-date.
Declaration
public bool CanConnectToDatabase { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsDatabaseConfigured
Gets a value indicating whether the database is configured. It does not necessarily mean that it is possible to connect, nor that Umbraco is installed, nor up-to-date.
Declaration
public bool IsDatabaseConfigured { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
View SourceCanConnect(String, String)
Verifies whether a it is possible to connect to a database.
Declaration
public bool CanConnect(string connectionString, string providerName)
Parameters
Type | Name | Description |
---|---|---|
System.String | connectionString | |
System.String | providerName |
Returns
Type | Description |
---|---|
System.Boolean |
ConfigureDatabaseConnection(DatabaseModel, Boolean)
Declaration
public bool ConfigureDatabaseConnection(DatabaseModel databaseSettings, bool isTrialRun)
Parameters
Type | Name | Description |
---|---|---|
DatabaseModel | databaseSettings | |
System.Boolean | isTrialRun |
Returns
Type | Description |
---|---|
System.Boolean |
CreateDatabase()
Declaration
public void CreateDatabase()
CreateSchemaAndData()
Creates the database schema and inserts initial data.
Declaration
public DatabaseBuilder.Result CreateSchemaAndData()
Returns
Type | Description |
---|---|
DatabaseBuilder.Result |
Remarks
This assumes that the database exists and the connection string is configured and it is possible to connect to the database.
HasSomeNonDefaultUser()
Declaration
public bool HasSomeNonDefaultUser()
Returns
Type | Description |
---|---|
System.Boolean |
UpgradeSchemaAndData(UmbracoPlan)
Upgrades the database schema and data by running migrations.
Declaration
public DatabaseBuilder.Result UpgradeSchemaAndData(UmbracoPlan plan)
Parameters
Type | Name | Description |
---|---|---|
UmbracoPlan | plan |
Returns
Type | Description |
---|---|
DatabaseBuilder.Result |
Remarks
This assumes that the database exists and the connection string is configured and it is possible to connect to the database.
Runs whichever migrations need to run.
ValidateSchema()
Validates the database schema.
Declaration
public DatabaseSchemaResult ValidateSchema()
Returns
Type | Description |
---|---|
DatabaseSchemaResult |
Remarks
This assumes that the database exists and the connection string is configured and it is possible to connect to the database.