/// <summary> /// Initializes the database by creating the umbraco db schema. /// </summary> /// <remarks>This needs to execute as part of a transaction.</remarks> public void InitializeDatabaseSchema() { if (!_database.InTransaction) { throw new InvalidOperationException("Database is not in a transaction."); } var eventMessages = new EventMessages(); var creatingNotification = new DatabaseSchemaCreatingNotification(eventMessages); FireBeforeCreation(creatingNotification); if (creatingNotification.Cancel == false) { var dataCreation = new DatabaseDataCreator(_database, _loggerFactory.CreateLogger <DatabaseDataCreator>(), _umbracoVersion); foreach (var table in OrderedTables) { CreateTable(false, table, dataCreation); } } DatabaseSchemaCreatedNotification createdNotification = new DatabaseSchemaCreatedNotification(eventMessages).WithStateFrom(creatingNotification); FireAfterCreation(createdNotification); }
/// <summary> /// Publishes the <see cref="Notifications.DatabaseSchemaCreatingNotification"/> notification. /// </summary> /// <param name="notification">Cancelable notification marking the creation having begun.</param> internal virtual void FireBeforeCreation(DatabaseSchemaCreatingNotification notification) => _eventAggregator.Publish(notification);