Ensures the migrations table is created on install, updates the installation to create the latest migration version once complete.

This commit is contained in:
Shannon
2015-06-22 19:31:34 +02:00
parent 38953212a3
commit ff7bdb0f5b
4 changed files with 15 additions and 7 deletions

View File

@@ -542,7 +542,7 @@ namespace Umbraco.Core
return _result;
}
internal Result CreateDatabaseSchemaAndData()
internal Result CreateDatabaseSchemaAndData(ApplicationContext applicationContext)
{
try
{
@@ -584,7 +584,9 @@ namespace Umbraco.Core
//If Configuration Status is empty and the determined version is "empty" its a new install - otherwise upgrade the existing
if (string.IsNullOrEmpty(GlobalSettings.ConfigurationStatus) && installedVersion.Equals(new Version(0, 0, 0)))
{
database.CreateDatabaseSchema();
var helper = new DatabaseSchemaHelper(database, _logger, SqlSyntax);
helper.CreateDatabaseSchema(true, applicationContext);
message = message + "<p>Installation completed!</p>";
//now that everything is done, we need to determine the version of SQL server that is executing

View File

@@ -1,10 +1,12 @@
using System;
using System.Linq;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
using Umbraco.Core.Persistence.Migrations.Initial;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Services;
namespace Umbraco.Core.Persistence
{
@@ -60,7 +62,7 @@ namespace Umbraco.Core.Persistence
if (guardConfiguration && applicationContext.IsConfigured)
throw new Exception("Umbraco is already configured!");
CreateDatabaseSchemaDo();
CreateDatabaseSchemaDo(applicationContext.Services.MigrationEntryService);
}
internal void CreateDatabaseSchemaDo(bool guardConfiguration, ApplicationContext applicationContext)
@@ -68,16 +70,19 @@ namespace Umbraco.Core.Persistence
if (guardConfiguration && applicationContext.IsConfigured)
throw new Exception("Umbraco is already configured!");
CreateDatabaseSchemaDo();
CreateDatabaseSchemaDo(applicationContext.Services.MigrationEntryService);
}
internal void CreateDatabaseSchemaDo()
internal void CreateDatabaseSchemaDo(IMigrationEntryService migrationEntryService)
{
_logger.Info<Database>("Initializing database schema creation");
var creation = new DatabaseSchemaCreation(_db, _logger, _syntaxProvider);
creation.InitializeDatabaseSchema();
//Now ensure to cretae the tag in the db for the current migration version
migrationEntryService.CreateEntry(GlobalSettings.UmbracoMigrationName, UmbracoVersion.Current);
_logger.Info<Database>("Finalized database schema creation");
}

View File

@@ -82,7 +82,8 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
{41, typeof (AccessDto)},
{42, typeof (AccessRuleDto)},
{43, typeof(CacheInstructionDto)},
{44, typeof (ExternalLoginDto)}
{44, typeof (ExternalLoginDto)},
{45, typeof (MigrationDto)}
};
#endregion

View File

@@ -21,7 +21,7 @@ namespace Umbraco.Web.Install.InstallSteps
public override InstallSetupResult Execute(object model)
{
var result = _applicationContext.DatabaseContext.CreateDatabaseSchemaAndData();
var result = _applicationContext.DatabaseContext.CreateDatabaseSchemaAndData(_applicationContext);
if (result.Success == false)
{