Gets the stylesheet migrations all working, updates other post migrations to use a common base class, adds ILogger to the MigrationContext

This commit is contained in:
Shannon
2015-01-16 10:57:49 +11:00
parent 3fdf13a8b1
commit 6f76377a9e
16 changed files with 294 additions and 118 deletions

View File

@@ -1,4 +1,6 @@
namespace Umbraco.Core using System;
namespace Umbraco.Core
{ {
public static partial class Constants public static partial class Constants
{ {
@@ -70,8 +72,10 @@
/// <summary> /// <summary>
/// Guid for a Stylesheet object. /// Guid for a Stylesheet object.
/// </summary> /// </summary>
public const string Stylesheet = "9F68DA4F-A3A8-44C2-8226-DCBD125E4840"; [Obsolete("This no longer exists in the database")]
public const string Stylesheet = "9F68DA4F-A3A8-44C2-8226-DCBD125E4840";
[Obsolete("This no longer exists in the database")]
internal const string StylesheetProperty = "5555da4f-a123-42b2-4488-dcdfb25e4111"; internal const string StylesheetProperty = "5555da4f-a123-42b2-4488-dcdfb25e4111";
/// <summary> /// <summary>

View File

@@ -1,34 +0,0 @@
using System;
using System.Threading;
using Umbraco.Core.Configuration;
namespace Umbraco.Core.Persistence
{
/// <summary>
/// Provides access to the PetaPoco database as Singleton, so the database is created once in app lifecycle.
/// This is necessary for transactions to work properly
/// </summary>
public sealed class DatabaseFactory
{
#region Singleton
private static readonly Database _database = new Database(GlobalSettings.DbDsn);
private static readonly Lazy<DatabaseFactory> lazy = new Lazy<DatabaseFactory>(() => new DatabaseFactory());
public static DatabaseFactory Current { get { return lazy.Value; } }
private DatabaseFactory()
{
}
#endregion
/// <summary>
/// Returns an instance of the PetaPoco database
/// </summary>
public Database Database
{
get { return _database; }
}
}
}

View File

@@ -1,15 +1,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using Umbraco.Core.Logging;
namespace Umbraco.Core.Persistence.Migrations namespace Umbraco.Core.Persistence.Migrations
{ {
internal class MigrationContext : IMigrationContext internal class MigrationContext : IMigrationContext
{ {
public MigrationContext(DatabaseProviders databaseProvider, Database database) public MigrationContext(DatabaseProviders databaseProvider, Database database, ILogger logger)
{ {
Expressions = new Collection<IMigrationExpression>(); Expressions = new Collection<IMigrationExpression>();
CurrentDatabaseProvider = databaseProvider; CurrentDatabaseProvider = databaseProvider;
Database = database; Database = database;
Logger = logger;
} }
public ICollection<IMigrationExpression> Expressions { get; set; } public ICollection<IMigrationExpression> Expressions { get; set; }
@@ -17,5 +19,7 @@ namespace Umbraco.Core.Persistence.Migrations
public DatabaseProviders CurrentDatabaseProvider { get; private set; } public DatabaseProviders CurrentDatabaseProvider { get; private set; }
public Database Database { get; private set; } public Database Database { get; private set; }
public ILogger Logger { get; private set; }
} }
} }

View File

@@ -9,7 +9,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZe
/// <summary> /// <summary>
/// Remove the master column after we've migrated all of the values into the 'ParentId' and Path column of Umbraco node /// Remove the master column after we've migrated all of the values into the 'ParentId' and Path column of Umbraco node
/// </summary> /// </summary>
[Migration("7.3.0", 0, GlobalSettings.UmbracoMigrationName)] [Migration("7.3.0", 1, GlobalSettings.UmbracoMigrationName)]
public class MigrateAndRemoveTemplateMasterColumn : MigrationBase public class MigrateAndRemoveTemplateMasterColumn : MigrationBase
{ {
public override void Up() public override void Up()

View File

@@ -0,0 +1,132 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Models;
using File = System.IO.File;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZero
{
/// <summary>
/// Ensures that any stylesheets that have properties defined at the db level have the correct new syntax
/// in their files before we remove the stylesheet db tables
/// </summary>
/// <remarks>
/// Instead of modifying the files directly (since we cannot roll them back) we will create temporary migrated files.
/// These files will then be copied over once the entire migration is complete so that if any migration fails and the db changes are
/// rolled back, the original files won't be affected.
/// </remarks>
[Migration("7.3.0", 2, GlobalSettings.UmbracoMigrationName)]
public class MigrateStylesheetDataToFile : MigrationBase
{
public override void Up()
{
//This is all rather nasty but it's how stylesheets used to work in the 2 various ugly ways so we just have to
// deal with that to get this migration done
var tempFolder = IOHelper.MapPath("~/App_Data/TEMP/CssMigration/");
if (Directory.Exists(tempFolder))
{
//clear any existing css files (we back the real ones up so if this migration is run again for whatever reason anything that
// was previously backed up is still there, backup happens in a post migration: OverwriteStylesheetFilesFromTempFiles class)
var files = Directory.GetFiles(tempFolder, "*.css", SearchOption.AllDirectories);
foreach (var file in files)
{
File.Delete(file);
}
}
//create the temp folder
var tempDir = Directory.CreateDirectory(IOHelper.MapPath("~/App_Data/TEMP/CssMigration/"));
var sheets = Context.Database.Fetch<dynamic>("SELECT * FROM cmsStylesheet INNER JOIN umbracoNode on cmsStylesheet.nodeId = umbracoNode.id");
foreach (var sheet in sheets)
{
var fileName = sheet.text;
string dbContent;
//we will always use the file content over the db content if there is any
using (var memStream = new MemoryStream(Encoding.UTF8.GetBytes(sheet.content)))
{
dbContent = GetContentAboveUmbracoProps(memStream);
}
var fileContent = string.Empty;
//check for file and read in it's data - umbraco properties will only be kept that are in the db,
// anything below the infamous: /* EDITOR PROPERTIES - PLEASE DON'T DELETE THIS LINE TO AVOID DUPLICATE PROPERTIES */
// line is an Umbraco property and therefore anything that is there that is not in the db will be cleared.
var filePath = IOHelper.MapPath(string.Format("{0}/{1}.css", SystemDirectories.Css, fileName));
if (File.Exists(filePath))
{
using (var stream = File.OpenRead(filePath))
{
fileContent = GetContentAboveUmbracoProps(stream);
}
}
var props = Context.Database.Fetch<dynamic>("SELECT * FROM cmsStylesheetProperty INNER JOIN umbracoNode ON cmsStylesheetProperty.nodeId = umbracoNode.id WHere umbracoNode.parentID = @id", new { id = sheet.nodeId });
var cssFolderPath = IOHelper.MapPath(SystemDirectories.Css);
var relativeFsPath = StringExtensions.TrimStart(StringExtensions.TrimStart(filePath, cssFolderPath), "\\");
var stylesheetInstance = new Stylesheet(relativeFsPath)
{
Content = fileContent.IsNullOrWhiteSpace() ? dbContent : fileContent
};
foreach (var prop in props)
{
if (stylesheetInstance.Properties.Any(x => x.Name == prop.text) == false)
{
stylesheetInstance.AddProperty(new StylesheetProperty(prop.text, prop.stylesheetPropertyAlias, prop.stylesheetPropertyValue));
}
}
//Save to temp folder
//ensure the folder for the file exists since it could be in a sub folder
var tempFilePath = Path.Combine(tempDir.FullName, relativeFsPath);
Directory.CreateDirectory(Path.GetDirectoryName(tempFilePath));
File.WriteAllText(tempFilePath, stylesheetInstance.Content, Encoding.UTF8);
}
}
public override void Down()
{
throw new NotSupportedException("Cannot downgrade from 7.3 as there are database table deletions");
}
private string GetContentAboveUmbracoProps(Stream stream)
{
var content = string.Empty;
using (var re = new StreamReader(stream))
{
string input;
var readingProperties = false;
while ((input = re.ReadLine()) != null)
{
//This is that line that was in there before that was delimiting umb props from normal css:
// /* EDITOR PROPERTIES - PLEASE DON'T DELETE THIS LINE TO AVOID DUPLICATE PROPERTIES */
if (input.Contains("EDITOR PROPERTIES"))
{
readingProperties = true;
continue;
}
if (readingProperties == false)
{
content += input;
}
}
}
return content;
}
}
}

View File

@@ -319,6 +319,7 @@
<Compile Include="Logging\DebugDiagnosticsLogger.cs" /> <Compile Include="Logging\DebugDiagnosticsLogger.cs" />
<Compile Include="Logging\LoggerExtensions.cs" /> <Compile Include="Logging\LoggerExtensions.cs" />
<Compile Include="Logging\LoggerResolver.cs" /> <Compile Include="Logging\LoggerResolver.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\MigrateStylesheetDataToFile.cs" />
<Compile Include="Strings\Css\StylesheetHelper.cs" /> <Compile Include="Strings\Css\StylesheetHelper.cs" />
<Compile Include="Models\IPartialView.cs" /> <Compile Include="Models\IPartialView.cs" />
<Compile Include="Persistence\DatabaseSchemaHelper.cs" /> <Compile Include="Persistence\DatabaseSchemaHelper.cs" />
@@ -401,7 +402,7 @@
<Compile Include="Persistence\Mappers\TagMapper.cs" /> <Compile Include="Persistence\Mappers\TagMapper.cs" />
<Compile Include="Persistence\Mappers\TemplateMapper.cs" /> <Compile Include="Persistence\Mappers\TemplateMapper.cs" />
<Compile Include="Persistence\Migrations\DataLossException.cs" /> <Compile Include="Persistence\Migrations\DataLossException.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\RemoveTemplateMasterColumn.cs" /> <Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\MigrateAndRemoveTemplateMasterColumn.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\AddRelationTypeForDocumentOnDelete.cs" /> <Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\AddRelationTypeForDocumentOnDelete.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenTwoZero\AddMissingForeignKeyForContentType.cs" /> <Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenTwoZero\AddMissingForeignKeyForContentType.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenTwoZero\AlterDataTypePreValueTable.cs" /> <Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenTwoZero\AlterDataTypePreValueTable.cs" />

View File

@@ -1,4 +1,5 @@
using System.Web; using System.Web;
using Umbraco.Core.Events;
using Umbraco.Core.Persistence.Migrations; using Umbraco.Core.Persistence.Migrations;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
using umbraco.interfaces; using umbraco.interfaces;
@@ -8,14 +9,9 @@ namespace Umbraco.Web.Strategies.Migrations
/// <summary> /// <summary>
/// After upgrade we clear out the csrf tokens /// After upgrade we clear out the csrf tokens
/// </summary> /// </summary>
public class ClearCsrfCookiesAfterUpgrade : IApplicationStartupHandler public class ClearCsrfCookiesAfterUpgrade : MigrationStartupHander
{ {
public ClearCsrfCookiesAfterUpgrade() protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
{
MigrationRunner.Migrated += MigrationRunner_Migrated;
}
void MigrationRunner_Migrated(MigrationRunner sender, Core.Events.MigrationEventArgs e)
{ {
if (HttpContext.Current == null) return; if (HttpContext.Current == null) return;

View File

@@ -1,5 +1,6 @@
using System; using System;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Logging; using Umbraco.Core.Logging;
using Umbraco.Core.Persistence.Migrations; using Umbraco.Core.Persistence.Migrations;
using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Core.Persistence.SqlSyntax;
@@ -15,14 +16,9 @@ namespace Umbraco.Web.Strategies.Migrations
/// ///
/// * If current is less than or equal to 7.0.0 /// * If current is less than or equal to 7.0.0
/// </remarks> /// </remarks>
public class ClearMediaXmlCacheForDeletedItemsAfterUpgrade : IApplicationStartupHandler public class ClearMediaXmlCacheForDeletedItemsAfterUpgrade : MigrationStartupHander
{ {
public ClearMediaXmlCacheForDeletedItemsAfterUpgrade() protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
{
MigrationRunner.Migrated += MigrationRunner_Migrated;
}
void MigrationRunner_Migrated(MigrationRunner sender, Core.Events.MigrationEventArgs e)
{ {
var target70 = new Version(7, 0, 0); var target70 = new Version(7, 0, 0);
@@ -34,7 +30,7 @@ namespace Umbraco.Web.Strategies.Migrations
var sql = @"DELETE FROM cmsContentXml WHERE nodeId IN var sql = @"DELETE FROM cmsContentXml WHERE nodeId IN
(SELECT nodeId FROM (SELECT DISTINCT cmsContentXml.nodeId FROM cmsContentXml (SELECT nodeId FROM (SELECT DISTINCT cmsContentXml.nodeId FROM cmsContentXml
INNER JOIN umbracoNode ON cmsContentXml.nodeId = umbracoNode.id INNER JOIN umbracoNode ON cmsContentXml.nodeId = umbracoNode.id
WHERE nodeObjectType = '" + Constants.ObjectTypes.Media +"' AND " + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("path") + " LIKE '%-21%') x)"; WHERE nodeObjectType = '" + Constants.ObjectTypes.Media + "' AND " + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("path") + " LIKE '%-21%') x)";
var count = e.MigrationContext.Database.Execute(sql); var count = e.MigrationContext.Database.Execute(sql);

View File

@@ -1,4 +1,5 @@
using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix; using Umbraco.Core;
using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix;
using umbraco.BusinessLogic; using umbraco.BusinessLogic;
using umbraco.interfaces; using umbraco.interfaces;
@@ -8,14 +9,30 @@ namespace Umbraco.Web.Strategies.Migrations
/// This is kind of a hack to ensure that Apps and Trees that might still reside in the db is /// This is kind of a hack to ensure that Apps and Trees that might still reside in the db is
/// written to the 'new' applications.config and trees.config files upon upgrade to version 6.0 /// written to the 'new' applications.config and trees.config files upon upgrade to version 6.0
/// </summary> /// </summary>
public class EnsureAppsTreesUpdatedOnUpgrade : IApplicationStartupHandler public class EnsureAppsTreesUpdatedOnUpgrade : ApplicationEventHandler
{ {
public EnsureAppsTreesUpdatedOnUpgrade() /// <summary>
/// Ensure this is run when not configured
/// </summary>
protected override bool ExecuteWhenApplicationNotConfigured
{
get { return true; }
}
/// <summary>
/// Ensure this is run when not configured
/// </summary>
protected override bool ExecuteWhenDatabaseNotConfigured
{
get { return true; }
}
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{ {
//This event will be triggered once the EnsureAppsTreesUpdated Up() method is run during upgrades //This event will be triggered once the EnsureAppsTreesUpdated Up() method is run during upgrades
EnsureAppsTreesUpdated.Upgrading += EnsureAppsTreesUpdated_Upgrading; EnsureAppsTreesUpdated.Upgrading += EnsureAppsTreesUpdated_Upgrading;
} }
void EnsureAppsTreesUpdated_Upgrading(object sender, EnsureAppsTreesUpdated.UpgradingEventArgs e) void EnsureAppsTreesUpdated_Upgrading(object sender, EnsureAppsTreesUpdated.UpgradingEventArgs e)
{ {
var treeRegistrar = new ApplicationTreeRegistrar(); var treeRegistrar = new ApplicationTreeRegistrar();

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Models; using Umbraco.Core.Models;
using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence; using Umbraco.Core.Persistence;
@@ -15,46 +16,20 @@ namespace Umbraco.Web.Strategies.Migrations
/// <summary> /// <summary>
/// Creates the built in list view data types /// Creates the built in list view data types
/// </summary> /// </summary>
public class EnsureDefaultListViewDataTypesCreated : ApplicationEventHandler public class EnsureDefaultListViewDataTypesCreated : MigrationStartupHander
{ {
/// <summary> protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
/// Ensure this is run when not configured
/// </summary>
protected override bool ExecuteWhenApplicationNotConfigured
{
get { return true; }
}
/// <summary>
/// Ensure this is run when not configured
/// </summary>
protected override bool ExecuteWhenDatabaseNotConfigured
{
get { return true; }
}
/// <summary>
/// Attach to event on starting
/// </summary>
/// <param name="umbracoApplication"></param>
/// <param name="applicationContext"></param>
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
MigrationRunner.Migrated += MigrationRunner_Migrated;
}
void MigrationRunner_Migrated(MigrationRunner sender, Core.Events.MigrationEventArgs e)
{ {
var target720 = new Version(7, 2, 0); var target720 = new Version(7, 2, 0);
if (e.ConfiguredVersion <= target720) if (e.ConfiguredVersion <= target720)
{ {
EnsureListViewDataTypeCreated(e); EnsureListViewDataTypeCreated(e);
} }
} }
private void EnsureListViewDataTypeCreated(Core.Events.MigrationEventArgs e) private void EnsureListViewDataTypeCreated(MigrationEventArgs e)
{ {
var exists = e.MigrationContext.Database.ExecuteScalar<int>("SELECT COUNT(*) FROM umbracoNode WHERE id=1037"); var exists = e.MigrationContext.Database.ExecuteScalar<int>("SELECT COUNT(*) FROM umbracoNode WHERE id=1037");
if (exists > 0) return; if (exists > 0) return;

View File

@@ -0,0 +1,49 @@
using Umbraco.Core;
using Umbraco.Core.Persistence.Migrations;
namespace Umbraco.Web.Strategies.Migrations
{
/// <summary>
/// Base class that can be used to run code after the migration runner has executed
/// </summary>
public abstract class MigrationStartupHander : ApplicationEventHandler
{
/// <summary>
/// Ensure this is run when not configured
/// </summary>
protected override bool ExecuteWhenApplicationNotConfigured
{
get { return true; }
}
/// <summary>
/// Ensure this is run when not configured
/// </summary>
protected override bool ExecuteWhenDatabaseNotConfigured
{
get { return true; }
}
public void Unsubscribe()
{
MigrationRunner.Migrated -= MigrationRunner_Migrated;
}
/// <summary>
/// Attach to event on starting
/// </summary>
/// <param name="umbracoApplication"></param>
/// <param name="applicationContext"></param>
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
MigrationRunner.Migrated += MigrationRunner_Migrated;
}
private void MigrationRunner_Migrated(MigrationRunner sender, Core.Events.MigrationEventArgs e)
{
AfterMigration(sender, e);
}
protected abstract void AfterMigration(MigrationRunner sender, Core.Events.MigrationEventArgs e);
}
}

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Core.Events;
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence.Migrations;
namespace Umbraco.Web.Strategies.Migrations
{
/// <summary>
/// When upgrading version 7.3 the migration MigrateStylesheetDataToFile will execute but we don't want to overwrite the developers
/// files during the migration since other parts of the migration might fail. So once the migration is complete, we'll then copy over the temp
/// files that this migration created over top of the developer's files. We'll also create a backup of their files.
/// </summary>
public sealed class OverwriteStylesheetFilesFromTempFiles : MigrationStartupHander
{
protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
{
var target73 = new Version(7, 3, 0);
if (e.ConfiguredVersion <= target73)
{
var tempCssFolder = IOHelper.MapPath("~/App_Data/TEMP/CssMigration/");
var cssFolder = IOHelper.MapPath("~/css");
if (Directory.Exists(tempCssFolder))
{
var files = Directory.GetFiles(tempCssFolder, "*.css", SearchOption.AllDirectories);
foreach (var file in files)
{
var relativePath = file.TrimStart(tempCssFolder).TrimStart("\\");
var cssFilePath = Path.Combine(cssFolder, relativePath);
if (File.Exists(cssFilePath))
{
//backup
var targetPath = Path.Combine(tempCssFolder, relativePath.EnsureEndsWith(".bak"));
e.MigrationContext.Logger.Info<OverwriteStylesheetFilesFromTempFiles>("CSS file is being backed up from {0}, to {1} before being migrated to new format", () => cssFilePath, () => targetPath);
File.Copy(cssFilePath, targetPath, true);
}
//ensure the sub folder eixts
Directory.CreateDirectory(Path.GetDirectoryName(cssFilePath));
File.Copy(file, cssFilePath, true);
}
}
}
}
}
}

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Umbraco.Core.Events;
using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence; using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Migrations; using Umbraco.Core.Persistence.Migrations;
@@ -14,19 +15,9 @@ namespace Umbraco.Web.Strategies.Migrations
/// This event ensures that upgrades from (configured) versions lower then 6.0.0 /// This event ensures that upgrades from (configured) versions lower then 6.0.0
/// have their publish state updated after the database schema has been migrated. /// have their publish state updated after the database schema has been migrated.
/// </summary> /// </summary>
public class PublishAfterUpgradeToVersionSixth : IApplicationStartupHandler public class PublishAfterUpgradeToVersionSixth : MigrationStartupHander
{ {
public PublishAfterUpgradeToVersionSixth() protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
{
MigrationRunner.Migrated += MigrationRunner_Migrated;
}
public void Unsubscribe()
{
MigrationRunner.Migrated -= MigrationRunner_Migrated;
}
void MigrationRunner_Migrated(MigrationRunner sender, Core.Events.MigrationEventArgs e)
{ {
var target = new Version(6, 0, 0); var target = new Version(6, 0, 0);
if (e.ConfiguredVersion < target) if (e.ConfiguredVersion < target)
@@ -43,8 +34,6 @@ namespace Umbraco.Web.Strategies.Migrations
.Where<NodeDto>(x => x.NodeObjectType == new Guid(Constants.ObjectTypes.Document)) .Where<NodeDto>(x => x.NodeObjectType == new Guid(Constants.ObjectTypes.Document))
.Where<NodeDto>(x => x.Path.StartsWith("-1")); .Where<NodeDto>(x => x.Path.StartsWith("-1"));
var dtos = e.MigrationContext.Database.Fetch<DocumentDto, ContentVersionDto, ContentDto, NodeDto>(sql); var dtos = e.MigrationContext.Database.Fetch<DocumentDto, ContentVersionDto, ContentDto, NodeDto>(sql);
var toUpdate = new List<DocumentDto>(); var toUpdate = new List<DocumentDto>();
var versionGroup = dtos.GroupBy(x => x.NodeId); var versionGroup = dtos.GroupBy(x => x.NodeId);
@@ -80,6 +69,7 @@ namespace Umbraco.Web.Strategies.Migrations
transaction.Complete(); transaction.Complete();
} }
} }
} }
} }
} }

View File

@@ -1,5 +1,6 @@
using System; using System;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Persistence.Migrations; using Umbraco.Core.Persistence.Migrations;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using umbraco.interfaces; using umbraco.interfaces;
@@ -16,14 +17,9 @@ namespace Umbraco.Web.Strategies.Migrations
/// ///
/// * If current is less than or equal to 7.0.0 /// * If current is less than or equal to 7.0.0
/// </remarks> /// </remarks>
public class RebuildMediaXmlCacheAfterUpgrade : IApplicationStartupHandler public class RebuildMediaXmlCacheAfterUpgrade : MigrationStartupHander
{ {
public RebuildMediaXmlCacheAfterUpgrade() protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
{
MigrationRunner.Migrated += MigrationRunner_Migrated;
}
void MigrationRunner_Migrated(MigrationRunner sender, Core.Events.MigrationEventArgs e)
{ {
var target70 = new Version(7, 0, 0); var target70 = new Version(7, 0, 0);
@@ -32,7 +28,6 @@ namespace Umbraco.Web.Strategies.Migrations
var mediasvc = (MediaService)ApplicationContext.Current.Services.MediaService; var mediasvc = (MediaService)ApplicationContext.Current.Services.MediaService;
mediasvc.RebuildXmlStructures(); mediasvc.RebuildXmlStructures();
} }
} }
} }
} }

View File

@@ -501,6 +501,8 @@
<Compile Include="Strategies\Migrations\ClearCsrfCookiesAfterUpgrade.cs" /> <Compile Include="Strategies\Migrations\ClearCsrfCookiesAfterUpgrade.cs" />
<Compile Include="Strategies\Migrations\ClearMediaXmlCacheForDeletedItemsAfterUpgrade.cs" /> <Compile Include="Strategies\Migrations\ClearMediaXmlCacheForDeletedItemsAfterUpgrade.cs" />
<Compile Include="Strategies\Migrations\EnsureListViewDataTypeIsCreated.cs" /> <Compile Include="Strategies\Migrations\EnsureListViewDataTypeIsCreated.cs" />
<Compile Include="Strategies\Migrations\MigrationStartupHander.cs" />
<Compile Include="Strategies\Migrations\OverwriteStylesheetFilesFromTempFiles.cs" />
<Compile Include="Strategies\NotificationsHandler.cs" /> <Compile Include="Strategies\NotificationsHandler.cs" />
<Compile Include="Strategies\RelateOnCopyHandler.cs" /> <Compile Include="Strategies\RelateOnCopyHandler.cs" />
<Compile Include="TagQuery.cs" /> <Compile Include="TagQuery.cs" />

View File

@@ -110,12 +110,7 @@ namespace umbraco.cms.businesslogic.web
public override string Text public override string Text
{ {
get { return Filename; } get { return Filename; }
set set { Filename = value; }
{
var currFileName = System.IO.Path.GetFileName(StylesheetItem.Path);
var newFilePath = StylesheetItem.Path.TrimEnd(currFileName) + value;
StylesheetItem.Path = newFilePath;
}
} }
/// <summary> /// <summary>