/// <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="DatabaseSchemaCreatedNotification"/> notification. /// </summary> /// <param name="notification">Notification marking the creation having completed.</param> internal virtual void FireAfterCreation(DatabaseSchemaCreatedNotification notification) => _eventAggregator.Publish(notification);