Merge remote-tracking branch 'origin/6.2.0' into 7.1.0

Conflicts:
	src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs
	src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/AddChangeDocumentTypePermission.cs
	src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/AdditionalIndexesAndKeys.cs
	src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/AssignMissingPrimaryForMySqlKeys.cs
	src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/UpdateToNewMemberPropertyAliases.cs
	src/Umbraco.Core/Umbraco.Core.csproj
	src/Umbraco.Tests/Umbraco.Tests.csproj
	src/umbraco.controls/TreePicker/SimpleContentPicker.cs
This commit is contained in:
Shannon
2014-03-17 13:39:49 +11:00
30 changed files with 134 additions and 94 deletions

View File

@@ -9,7 +9,7 @@ namespace Umbraco.Core.Models.Rdbms
internal class UserLoginDto
{
[Column("contextID")]
[Index(IndexTypes.Clustered, Name = "umbracoUserLogins_Index")]
[Index(IndexTypes.Clustered, Name = "IX_umbracoUserLogins_Index")]
public Guid ContextId { get; set; }
[Column("userID")]

View File

@@ -21,9 +21,18 @@ namespace Umbraco.Core.Models
public RelationType(Guid childObjectType, Guid parentObjectType, string @alias)
{
Mandate.ParameterNotNullOrEmpty(@alias, "alias");
_childObjectType = childObjectType;
_parentObjectType = parentObjectType;
_alias = alias;
Name = _alias;
}
public RelationType(Guid childObjectType, Guid parentObjectType, string @alias, string name)
:this(childObjectType, parentObjectType, @alias)
{
Mandate.ParameterNotNullOrEmpty(name, "name");
Name = name;
}
private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo<RelationType, string>(x => x.Name);

View File

@@ -5,15 +5,15 @@ namespace Umbraco.Core.Persistence.Migrations
/// <summary>
/// Used if a migration has executed but the whole process has failed and cannot be rolled back
/// </summary>
internal class CatastrophicDataLossException : Exception
internal class DataLossException : Exception
{
public CatastrophicDataLossException(string msg)
public DataLossException(string msg)
: base(msg)
{
}
public CatastrophicDataLossException(string msg, Exception inner)
public DataLossException(string msg, Exception inner)
: base(msg, inner)
{

View File

@@ -171,7 +171,8 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
x.Item3.InvariantStartsWith("FK_") == false && x.Item3.InvariantStartsWith("PK_") == false &&
x.Item3.InvariantStartsWith("IX_") == false).Select(x => x.Item3).ToList();
var foreignKeysInSchema = result.TableDefinitions.SelectMany(x => x.ForeignKeys.Select(y => y.Name)).ToList();
var primaryKeysInSchema = result.TableDefinitions.SelectMany(x => x.Columns.Select(y => y.PrimaryKeyName)).ToList();
var primaryKeysInSchema = result.TableDefinitions.SelectMany(x => x.Columns.Select(y => y.PrimaryKeyName))
.Where(x => x.IsNullOrWhiteSpace() == false).ToList();
//Add valid and invalid foreign key differences to the result object
foreach (var unknown in unknownConstraintsInDatabase)
@@ -283,7 +284,8 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
private void ValidateDbIndexes(DatabaseSchemaResult result)
{
//These are just column indexes NOT constraints or Keys
var colIndexesInDatabase = result.DbIndexDefinitions.Where(x => x.IndexName.InvariantStartsWith("IX_")).Select(x => x.IndexName).ToList();
//var colIndexesInDatabase = result.DbIndexDefinitions.Where(x => x.IndexName.InvariantStartsWith("IX_")).Select(x => x.IndexName).ToList();
var colIndexesInDatabase = result.DbIndexDefinitions.Select(x => x.IndexName).ToList();
var indexesInSchema = result.TableDefinitions.SelectMany(x => x.Indexes.Select(y => y.Name)).ToList();
//Add valid and invalid index differences to the result object

View File

@@ -48,26 +48,21 @@ namespace Umbraco.Core.Persistence.Migrations
var foundMigrations = MigrationResolver.Current.Migrations.ToArray();
//filter all schema migrations
var schemaMigrations = isUpgrade
? OrderedUpgradeMigrations(foundMigrations.Where(x => (x is SchemaMigration))).ToList()
: OrderedDowngradeMigrations(foundMigrations.Where(x => (x is SchemaMigration))).ToList();
//filter all non-schema migrations
var dataMigrations = isUpgrade
? OrderedUpgradeMigrations(foundMigrations.Where(x => (x is SchemaMigration) == false)).ToList()
: OrderedDowngradeMigrations(foundMigrations.Where(x => (x is SchemaMigration) == false)).ToList();
var migrations = isUpgrade
? OrderedUpgradeMigrations(foundMigrations).ToList()
: OrderedDowngradeMigrations(foundMigrations).ToList();
//SD: Why do we want this?
if (Migrating.IsRaisedEventCancelled(new MigrationEventArgs(dataMigrations, _currentVersion, _targetVersion, true), this))
if (Migrating.IsRaisedEventCancelled(new MigrationEventArgs(migrations, _configuredVersion, _targetVersion, true), this))
return false;
//Loop through migrations to generate sql
var schemaMigrationContext = InitializeMigrations(schemaMigrations, database, databaseProvider, isUpgrade);
var migrationContext = InitializeMigrations(migrations, database, databaseProvider, isUpgrade);
try
{
ExecuteMigrations(schemaMigrationContext, database);
ExecuteMigrations(migrationContext, database);
}
catch (Exception ex)
{
@@ -77,35 +72,16 @@ namespace Umbraco.Core.Persistence.Migrations
if (databaseProvider == DatabaseProviders.MySql)
{
try
{
var downgrades = OrderedDowngradeMigrations(foundMigrations.Where(x => (x is SchemaMigration))).ToList();
var downgradeMigrationContext = InitializeMigrations(downgrades, database, databaseProvider, false);
//lets hope that works! - if something cannot be rolled back then a CatastrophicDataLossException should
// be thrown.
ExecuteMigrations(downgradeMigrationContext, database);
}
catch (Exception e)
{
throw new CatastrophicDataLossException(
throw new DataLossException(
"An error occurred running a schema migration but the changes could not be rolled back. Error: " + ex.Message + ". In some cases, it may be required that the database be restored to it's original state before running this upgrade process again.",
ex);
}
}
//continue throwing the exception
throw;
}
//Ok, we've made it this far, now we can execute our data migrations
//Loop through migrations to generate sql
var dataMigrationContext = InitializeMigrations(dataMigrations, database, databaseProvider, isUpgrade);
//run them - if this fails the data will be rolled back
ExecuteMigrations(dataMigrationContext, database);
Migrated.RaiseEvent(new MigrationEventArgs(dataMigrations, dataMigrationContext, _currentVersion, _targetVersion, false), this);
Migrated.RaiseEvent(new MigrationEventArgs(migrations, migrationContext, _configuredVersion, _targetVersion, false), this);
return true;
}

View File

@@ -1,11 +0,0 @@
namespace Umbraco.Core.Persistence.Migrations
{
/// <summary>
/// A migration class that specifies that it is used for db schema migrations only - these need to execute first and MUST
/// have a downgrade plan.
/// </summary>
public abstract class SchemaMigration : MigrationBase
{
}
}

View File

@@ -4,7 +4,7 @@ using Umbraco.Core.Configuration;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionFourNineZero
{
[MigrationAttribute("4.9.0", 0, GlobalSettings.UmbracoMigrationName)]
public class RemoveUmbracoAppConstraints : SchemaMigration
public class RemoveUmbracoAppConstraints : MigrationBase
{
public override void Up()
{

View File

@@ -16,7 +16,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
public override void Down()
{
//This cannot be rolled back!!
throw new CatastrophicDataLossException("Cannot rollback migration " + typeof(DeleteAppTables) + " the db tables umbracoAppTree and umbracoApp have been droppped");
throw new DataLossException("Cannot rollback migration " + typeof(DeleteAppTables) + " the db tables umbracoAppTree and umbracoApp have been droppped");
}
}
}

View File

@@ -3,7 +3,7 @@
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
{
[Migration("6.0.0", 4, GlobalSettings.UmbracoMigrationName)]
public class NewCmsContentType2ContentTypeTable : SchemaMigration
public class NewCmsContentType2ContentTypeTable : MigrationBase
{
public override void Up()
{

View File

@@ -3,7 +3,7 @@
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
{
[Migration("6.0.0", 6, GlobalSettings.UmbracoMigrationName)]
public class RemoveMasterContentTypeColumn : SchemaMigration
public class RemoveMasterContentTypeColumn : MigrationBase
{
public override void Up()
{

View File

@@ -3,7 +3,7 @@
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
{
[Migration("6.0.0", 0, GlobalSettings.UmbracoMigrationName)]
public class RenameCmsTabTable : SchemaMigration
public class RenameCmsTabTable : MigrationBase
{
public override void Up()
{

View File

@@ -4,7 +4,7 @@ using Umbraco.Core.Configuration;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
{
[Migration("6.0.0", 7, GlobalSettings.UmbracoMigrationName)]
public class RenameTabIdColumn : SchemaMigration
public class RenameTabIdColumn : MigrationBase
{
public override void Up()
{

View File

@@ -3,7 +3,7 @@
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
{
[Migration("6.0.0", 3, GlobalSettings.UmbracoMigrationName)]
public class UpdateCmsContentTypeAllowedContentTypeTable : SchemaMigration
public class UpdateCmsContentTypeAllowedContentTypeTable : MigrationBase
{
public override void Up()
{

View File

@@ -3,7 +3,7 @@
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
{
[Migration("6.0.0", 2, GlobalSettings.UmbracoMigrationName)]
public class UpdateCmsContentTypeTable : SchemaMigration
public class UpdateCmsContentTypeTable : MigrationBase
{
public override void Up()
{

View File

@@ -3,7 +3,7 @@
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
{
[Migration("6.0.0", 8, GlobalSettings.UmbracoMigrationName)]
public class UpdateCmsContentVersionTable : SchemaMigration
public class UpdateCmsContentVersionTable : MigrationBase
{
public override void Up()
{

View File

@@ -4,7 +4,7 @@ using Umbraco.Core.Configuration;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
{
[Migration("6.0.0", 1, GlobalSettings.UmbracoMigrationName)]
public class UpdateCmsPropertyTypeGroupTable : SchemaMigration
public class UpdateCmsPropertyTypeGroupTable : MigrationBase
{
public override void Up()
{

View File

@@ -9,7 +9,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixOneZero
{
[Migration("6.1.0", 0, GlobalSettings.UmbracoMigrationName)]
public class CreateServerRegistryTable : SchemaMigration
public class CreateServerRegistryTable : MigrationBase
{
public override void Up()
{

View File

@@ -41,6 +41,17 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixTwoZero
{
Create.Index("IX_cmsDocument_newest").OnTable("cmsDocument").OnColumn("newest").Ascending().WithOptions().NonClustered();
}
//we want to drop the umbracoUserLogins_Index index since it is named incorrectly and then re-create it so
// it follows the standard naming convention
if (dbIndexes.Any(x => x.IndexName.InvariantEquals("umbracoUserLogins_Index")))
{
Delete.Index("umbracoUserLogins_Index").OnTable("umbracoUserLogins");
}
if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_umbracoUserLogins_Index")) == false)
{
Create.Index("IX_umbracoUserLogins_Index").OnTable("umbracoUserLogins").OnColumn("contextID").Ascending().WithOptions().Clustered();
}
}
public override void Down()

View File

@@ -5,7 +5,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixTwoZero
{
[Migration("7.1.0", 2, GlobalSettings.UmbracoMigrationName)]
[Migration("6.2.0", 2, GlobalSettings.UmbracoMigrationName)]
public class ChangePasswordColumn : SchemaMigration
public class ChangePasswordColumn : MigrationBase
{
public override void Up()
{

View File

@@ -532,7 +532,7 @@ namespace Umbraco.Core
public static bool InvariantContains(this IEnumerable<string> compare, string compareTo)
{
return compare.Contains(compareTo, new DelegateEqualityComparer<string>((source, dest) => source.Equals(dest, StringComparison.InvariantCultureIgnoreCase), x => x.GetHashCode()));
return compare.Contains(compareTo, StringComparer.InvariantCultureIgnoreCase);
}
/// <summary>

View File

@@ -364,8 +364,7 @@
<Compile Include="Persistence\EntityNotFoundException.cs" />
<Compile Include="Persistence\Factories\MemberGroupFactory.cs" />
<Compile Include="Persistence\Mappers\MemberGroupMapper.cs" />
<Compile Include="Persistence\Migrations\CatastrophicDataLossException.cs" />
<Compile Include="Persistence\Migrations\SchemaMigration.cs" />
<Compile Include="Persistence\Migrations\DataLossException.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenOneZero\AssignMissingPrimaryForMySqlKeys.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSixTwoZero\AssignMissingPrimaryForMySqlKeys.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSixTwoZero\ChangePasswordColumn.cs" />