Merge branch 'martin-blackwell-U4-8927' into dev-v7

This commit is contained in:
Sebastiaan Janssen
2018-04-12 14:36:21 +02:00

View File

@@ -166,17 +166,20 @@ namespace Umbraco.Core.Persistence.Migrations
var targetVersionToCompare = _targetVersion.GetVersion(3);
var currentVersionToCompare = _currentVersion.GetVersion(3);
if(currentVersionToCompare <= targetVersionToCompare)
throw new ArgumentException("When downgrading, make sure that the target version is lower than the current version.");
var migrations = (from migration in foundMigrations
let migrationAttributes = migration.GetType().GetCustomAttributes<MigrationAttribute>(false)
from migrationAttribute in migrationAttributes
where migrationAttribute != null
where
migrationAttribute.TargetVersion > currentVersionToCompare &&
migrationAttribute.TargetVersion <= targetVersionToCompare &&
migrationAttribute.TargetVersion > targetVersionToCompare &&
migrationAttribute.TargetVersion <= currentVersionToCompare &&
migrationAttribute.ProductName == _productName &&
//filter if the migration specifies a minimum current version for which to execute
(migrationAttribute.MinimumCurrentVersion == null || currentVersionToCompare >= migrationAttribute.MinimumCurrentVersion)
orderby migrationAttribute.TargetVersion, migrationAttribute.SortOrder descending
orderby migrationAttribute.TargetVersion descending, migrationAttribute.SortOrder descending
select migration).Distinct();
return migrations;
}