If the umbracoMigration table does not yet exist, then get the configured version from the web.config and parse it

This commit is contained in:
Sebastiaan Janssen
2016-07-26 16:19:17 +02:00
parent a83b524130
commit bb376367d6

View File

@@ -1,3 +1,5 @@
using System;
using System.Linq;
using Semver;
using Umbraco.Core;
using Umbraco.Core.Configuration;
@@ -52,12 +54,35 @@ namespace Umbraco.Web.Install.InstallSteps
//If we have a db context available, if we don't then we are not installed anyways
if (ApplicationContext.Current.DatabaseContext.IsDatabaseConfigured && ApplicationContext.Current.DatabaseContext.CanConnect)
{
version = ApplicationContext.Current.DatabaseContext.ValidateDatabaseSchema().DetermineInstalledVersionByMigrations(ApplicationContext.Current.Services.MigrationEntryService);
if (version != new SemVersion(0))
return version;
// If we aren't able to get a result from the umbracoMigrations table then use the version in web.config, if it's available
if (string.IsNullOrWhiteSpace(GlobalSettings.ConfigurationStatus))
return version;
var configuredVersion = GlobalSettings.ConfigurationStatus;
string currentComment = null;
var current = configuredVersion.Split('-');
if (current.Length > 1)
currentComment = current[1];
Version currentVersion;
if (Version.TryParse(current[0], out currentVersion))
{
version = new SemVersion(
currentVersion.Major,
currentVersion.Minor,
currentVersion.Build,
string.IsNullOrWhiteSpace(currentComment) ? null : currentComment,
currentVersion.Revision > 0 ? currentVersion.Revision.ToString() : null);
}
return version;
}
}
}