From 61441dd43688fc0559fdb216becd29ab8c8c69de Mon Sep 17 00:00:00 2001 From: Claus Date: Tue, 10 Nov 2015 12:15:44 +0100 Subject: [PATCH] Fixes: U4-7370 Upgrading from 7.3.1 to 7.4 fails cherrypicked from 7.4.0 branch. Added migration for 7.3.2, ensuring the identity on the table is correct. It failed due to rows initially being inserted with identity disabled and therefore the seed of the table was zero even when the table had data. --- .../EnsureMigrationsTableIdentityIsCorrect.cs | 34 +++++++++++++++++++ .../Repositories/RepositoryBase.cs | 2 +- src/Umbraco.Core/Umbraco.Core.csproj | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeTwo/EnsureMigrationsTableIdentityIsCorrect.cs diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeTwo/EnsureMigrationsTableIdentityIsCorrect.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeTwo/EnsureMigrationsTableIdentityIsCorrect.cs new file mode 100644 index 0000000000..ce70cdc407 --- /dev/null +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeTwo/EnsureMigrationsTableIdentityIsCorrect.cs @@ -0,0 +1,34 @@ +using Umbraco.Core.Configuration; +using Umbraco.Core.Logging; +using Umbraco.Core.Models.Rdbms; +using Umbraco.Core.Persistence.SqlSyntax; + +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeTwo +{ + /// + /// This reinserts all migrations in the migrations table to account for initial rows inserted + /// on creation without identity enabled. + /// + [Migration("7.3.2", 0, GlobalSettings.UmbracoMigrationName)] + public class EnsureMigrationsTableIdentityIsCorrect : MigrationBase + { + public EnsureMigrationsTableIdentityIsCorrect(ISqlSyntaxProvider sqlSyntax, ILogger logger) : base(sqlSyntax, logger) + { + } + + public override void Up() + { + Delete.FromTable("umbracoMigration").AllRows(); + var migrations = Context.Database.Fetch(new Sql().Select("*").From(SqlSyntax)); + foreach (var migration in migrations) + { + Insert.IntoTable("umbracoMigration") + .Row(new {name = migration.Name, createDate = migration.CreateDate, version = migration.Version}); + } + } + + public override void Down() + { + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/RepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/RepositoryBase.cs index f9088e1911..124aaeb035 100644 --- a/src/Umbraco.Core/Persistence/Repositories/RepositoryBase.cs +++ b/src/Umbraco.Core/Persistence/Repositories/RepositoryBase.cs @@ -297,7 +297,7 @@ namespace Umbraco.Core.Persistence.Repositories //If there's a GetAll zero count cache, ensure it is cleared RuntimeCache.ClearCacheItem(GetCacheTypeKey()); } - catch (Exception) + catch (Exception ex) { //if an exception is thrown we need to remove the entry from cache, this is ONLY a work around because of the way // that we cache entities: http://issues.umbraco.org/issue/U4-4259 diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 19e1d3e41e..f8cdcb10c2 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -404,6 +404,7 @@ +