Search Results for

    Show / Hide Table of Contents
    View Source

    Class DatabaseSchemaCreator

    Creates the initial database schema during install.

    Inheritance
    object
    Namespace: Umbraco.Cms.Infrastructure.Migrations.Install
    Assembly: Umbraco.Infrastructure.dll
    Syntax
    public class DatabaseSchemaCreator

    Constructors

    View Source

    DatabaseSchemaCreator(IUmbracoDatabase?, ILogger<DatabaseSchemaCreator>, ILoggerFactory, IUmbracoVersion, IEventAggregator, IOptionsMonitor<InstallDefaultDataSettings>)

    Initializes a new instance of the DatabaseSchemaCreator class.

    Declaration
    public DatabaseSchemaCreator(IUmbracoDatabase? database, ILogger<DatabaseSchemaCreator> logger, ILoggerFactory loggerFactory, IUmbracoVersion umbracoVersion, IEventAggregator eventAggregator, IOptionsMonitor<InstallDefaultDataSettings> defaultDataCreationSettings)
    Parameters
    Type Name Description
    IUmbracoDatabase database

    The Umbraco database instance to use for schema creation, or null if not provided.

    ILogger<DatabaseSchemaCreator> logger

    The logger used for logging schema creation operations.

    ILoggerFactory loggerFactory

    The factory used to create logger instances.

    IUmbracoVersion umbracoVersion

    Provides information about the current Umbraco version.

    IEventAggregator eventAggregator

    The event aggregator for publishing and subscribing to events during schema creation.

    IOptionsMonitor<InstallDefaultDataSettings> defaultDataCreationSettings

    The settings that control default data creation during installation.

    Methods

    View Source

    DropTable(string?)

    Drops the specified table from the database.

    Declaration
    public void DropTable(string? tableName)
    Parameters
    Type Name Description
    string tableName

    The name of the table to drop.

    View Source

    InitializeDatabaseSchema()

    Initializes the database by creating the umbraco db schema.

    Declaration
    public void InitializeDatabaseSchema()
    Remarks

    This needs to execute as part of a transaction.

    View Source

    TableExists(string?)

    Returns whether a table with the specified tableName exists in the database.

    Declaration
    public bool TableExists(string? tableName)
    Parameters
    Type Name Description
    string tableName

    The name of the table.

    Returns
    Type Description
    bool

    true if the table exists; otherwise false.

    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
    bool

    true if the table exists; otherwise false.

    Type Parameters
    Name Description
    T

    The type representing the DTO/table.

    Remarks

    If T has been decorated with an NPoco.TableNameAttribute, the name from that attribute will be used for the table name. If the attribute is not present, the name T will be used instead.

    Examples
    if (schemaHelper.TableExist<MyDto>)
    {
        // do something when the table exists
    }
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX