Fix 1.0 to 1.1 migration issue

SiteSettings are used very early and often in Orchard, so we
can't rely on having the user be able to run migration for
SiteSettings. The workaround for 1.1 is to move the changes
we did to SiteSettings into a new SiteSettings2 Part/Record.

With this change, database compatiblity from 1.0 and 1.1 seems
to be in a good working state on a real blog site.

--HG--
branch : 1.x
This commit is contained in:
Renaud Paquay
2011-04-07 18:29:23 -07:00
parent 6b7efb2b8f
commit db3046f68f
7 changed files with 38 additions and 11 deletions

View File

@@ -197,6 +197,8 @@
<Compile Include="Scheduling\Services\ScheduledTaskManager.cs" />
<Compile Include="Scheduling\Services\ScheduledTaskExecutor.cs" />
<Compile Include="Scheduling\Models\Task.cs" />
<Compile Include="Settings\Models\SiteSettings2Part.cs" />
<Compile Include="Settings\Models\SiteSettings2PartRecord.cs" />
<Compile Include="Settings\ResourceManifest.cs" />
<Compile Include="Settings\Migrations.cs" />
<Compile Include="Settings\Drivers\SiteSettingsPartDriver.cs" />

View File

@@ -6,9 +6,11 @@ using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Settings.Handlers {
[UsedImplicitly]
public class SiteSettingsPartHandler : ContentHandler {
public SiteSettingsPartHandler(IRepository<SiteSettingsPartRecord> repository){
public SiteSettingsPartHandler(IRepository<SiteSettingsPartRecord> repository, IRepository<SiteSettings2PartRecord> repository2) {
Filters.Add(new ActivatingFilter<SiteSettingsPart>("Site"));
Filters.Add(new ActivatingFilter<SiteSettings2Part>("Site"));
Filters.Add(StorageFilter.For(repository));
Filters.Add(StorageFilter.For(repository2));
}
}
}

View File

@@ -97,9 +97,10 @@ namespace Orchard.Core.Settings {
}
public int UpdateFrom1() {
SchemaBuilder.AlterTable("SiteSettingsPartRecord",
SchemaBuilder.CreateTable("SiteSettings2PartRecord",
table => table
.AddColumn<string>("BaseUrl", c => c.WithLength(255))
.ContentPartRecord()
.Column<string>("BaseUrl", c => c.Unlimited())
);
return 2;

View File

@@ -0,0 +1,12 @@
using Orchard.ContentManagement;
using Orchard.Data.Conventions;
namespace Orchard.Core.Settings.Models {
public sealed class SiteSettings2Part : ContentPart<SiteSettings2PartRecord> {
[StringLengthMax]
public string BaseUrl {
get { return Record.BaseUrl; }
set { Record.BaseUrl = value; }
}
}
}

View File

@@ -0,0 +1,9 @@
using Orchard.ContentManagement.Records;
using Orchard.Data.Conventions;
namespace Orchard.Core.Settings.Models {
public class SiteSettings2PartRecord : ContentPartRecord {
[StringLengthMax]
public virtual string BaseUrl { get; set; }
}
}

View File

@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using Orchard.ContentManagement;
using Orchard.Data.Conventions;
using Orchard.Settings;
namespace Orchard.Core.Settings.Models {
@@ -44,10 +45,14 @@ namespace Orchard.Core.Settings.Models {
set { Record.PageSize = value; }
}
[StringLength(255)]
[StringLengthMax]
public string BaseUrl {
get { return Record.BaseUrl; }
set { Record.BaseUrl = value; }
get {
return this.As<SiteSettings2Part>().BaseUrl;
}
set {
this.As<SiteSettings2Part>().BaseUrl = value;
}
}
}
}

View File

@@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations;
using Orchard.ContentManagement.Records;
using Orchard.ContentManagement.Records;
using Orchard.Settings;
namespace Orchard.Core.Settings.Models {
@@ -25,8 +24,5 @@ namespace Orchard.Core.Settings.Models {
public virtual ResourceDebugMode ResourceDebugMode { get; set; }
public virtual int PageSize { get; set; }
[StringLength(255)]
public virtual string BaseUrl { get; set; }
}
}