Fixing autoroute migrations

--HG--
branch : autoroute
This commit is contained in:
Sebastien Ros
2012-02-09 12:42:35 -08:00
parent 0e56e0fd64
commit 7b16bcf33a
@@ -72,20 +72,16 @@ namespace UpgradeTo14.Controllers {
foreach (var contentType in contentTypesToMigrate) {
if (_orchardServices.ContentManager.HqlQuery().ForType(contentType).Count() > 0 &&
_orchardServices.ContentManager.HqlQuery().ForType(contentType).Slice(0, 1).FirstOrDefault() == null) {
// can't load a content item, ignore the type
_orchardServices.Notifier.Information(T("Could not process {0}. Some parts might not be compatible with Orchard 1.4, please update your modules.", contentType));
continue;
}
// migrating parts
_contentDefinitionManager.AlterTypeDefinition(contentType,
builder => builder
.WithPart("AutoroutePart")
.WithPart("TitlePart"));
// force the first object to be reloaded in order to get a valid AutoroutePart
_orchardServices.ContentManager.Flush();
_orchardServices.ContentManager.Clear();
var count = 0;
var isContainable = false;
IEnumerable<ContentItem> contents;
@@ -102,7 +98,7 @@ namespace UpgradeTo14.Controllers {
isContainable = true;
}
using (new TransactionScope(TransactionScopeOption.Suppress)) {
using (new TransactionScope(TransactionScopeOption.RequiresNew)) {
var command = session.Connection.CreateCommand();
command.CommandText = string.Format("SELECT Title, Path FROM {0} WHERE ContentItemRecord_Id = {1}", GetPrefixedTableName("Routable_RoutePartRecord"), autoroutePart.ContentItem.Id);
var reader = command.ExecuteReader();
@@ -120,7 +116,7 @@ namespace UpgradeTo14.Controllers {
}
_orchardServices.ContentManager.Flush();
// todo: _orchardServices.ContentManager.Clear();
_orchardServices.ContentManager.Clear();
} while (contents.Any());