mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 10:54:50 +08:00
Use DataMigration API to create database tables for each feature
--HG-- branch : dev
This commit is contained in:
@@ -7,13 +7,15 @@ using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Data;
|
||||
using Orchard.DataMigration.Interpreters;
|
||||
using Orchard.Data.Migration;
|
||||
using Orchard.Data.Migration.Interpreters;
|
||||
using Orchard.Data.Migration.Records;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Folders;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Tests.ContentManagement;
|
||||
using Orchard.DataMigration;
|
||||
using Orchard.Data.Migration;
|
||||
using Orchard.Data.Providers;
|
||||
|
||||
namespace Orchard.Tests.DataMigration {
|
||||
@@ -90,20 +92,20 @@ namespace Orchard.Tests.DataMigration {
|
||||
}
|
||||
|
||||
public class DataMigrationEmpty : IDataMigration {
|
||||
public string Feature {
|
||||
get { return "Feature1"; }
|
||||
public Feature Feature {
|
||||
get { return new Feature() {Descriptor = new FeatureDescriptor() {Name = "Feature1"}}; }
|
||||
}
|
||||
}
|
||||
|
||||
public class DataMigration11 : IDataMigration {
|
||||
public string Feature {
|
||||
get { return "Feature1"; }
|
||||
public Feature Feature {
|
||||
get { return new Feature() {Descriptor = new FeatureDescriptor() {Name = "Feature1"}}; }
|
||||
}
|
||||
}
|
||||
|
||||
public class DataMigration11Create : IDataMigration {
|
||||
public string Feature {
|
||||
get { return "Feature1"; }
|
||||
public Feature Feature {
|
||||
get { return new Feature() {Descriptor = new FeatureDescriptor() {Name = "Feature1"}}; }
|
||||
}
|
||||
|
||||
public int Create() {
|
||||
@@ -112,8 +114,8 @@ namespace Orchard.Tests.DataMigration {
|
||||
}
|
||||
|
||||
public class DataMigrationCreateCanBeFollowedByUpdates : IDataMigration {
|
||||
public string Feature {
|
||||
get { return "Feature1"; }
|
||||
public Feature Feature {
|
||||
get { return new Feature() { Descriptor = new FeatureDescriptor() { Name = "Feature1" } }; }
|
||||
}
|
||||
|
||||
public int Create() {
|
||||
@@ -126,8 +128,8 @@ namespace Orchard.Tests.DataMigration {
|
||||
}
|
||||
|
||||
public class DataMigrationSameMigrationClassCanEvolve : IDataMigration {
|
||||
public string Feature {
|
||||
get { return "Feature1"; }
|
||||
public Feature Feature {
|
||||
get { return new Feature() { Descriptor = new FeatureDescriptor() { Name = "Feature1" } }; }
|
||||
}
|
||||
|
||||
public int Create() {
|
||||
@@ -144,8 +146,8 @@ namespace Orchard.Tests.DataMigration {
|
||||
}
|
||||
|
||||
public class DataMigrationDependenciesModule1 : IDataMigration {
|
||||
public string Feature {
|
||||
get { return "Feature1"; }
|
||||
public Feature Feature {
|
||||
get { return new Feature() {Descriptor = new FeatureDescriptor() {Name = "Feature1"}}; }
|
||||
}
|
||||
|
||||
public int Create() {
|
||||
@@ -154,8 +156,8 @@ namespace Orchard.Tests.DataMigration {
|
||||
}
|
||||
|
||||
public class DataMigrationDependenciesModule2 : IDataMigration {
|
||||
public string Feature {
|
||||
get { return "Feature2"; }
|
||||
public Feature Feature {
|
||||
get { return new Feature() { Descriptor = new FeatureDescriptor() { Name = "Feature2" } }; }
|
||||
}
|
||||
|
||||
public int Create() {
|
||||
@@ -164,8 +166,8 @@ namespace Orchard.Tests.DataMigration {
|
||||
}
|
||||
|
||||
public class DataMigrationWithSchemaBuilder : DataMigrationImpl {
|
||||
public override string Feature {
|
||||
get { return "Feature1"; }
|
||||
public override Feature Feature {
|
||||
get { return new Feature() { Descriptor = new FeatureDescriptor() { Name = "Feature1" } }; }
|
||||
}
|
||||
|
||||
public int Create() {
|
||||
@@ -175,14 +177,14 @@ namespace Orchard.Tests.DataMigration {
|
||||
}
|
||||
|
||||
public class DataMigrationFeatureNeedUpdate1 : IDataMigration {
|
||||
public string Feature {
|
||||
get { return "Feature1"; }
|
||||
public Feature Feature {
|
||||
get { return new Feature() { Descriptor = new FeatureDescriptor() { Name = "Feature1" } }; }
|
||||
}
|
||||
}
|
||||
|
||||
public class DataMigrationFeatureNeedUpdate2 : IDataMigration {
|
||||
public string Feature {
|
||||
get { return "Feature2"; }
|
||||
public Feature Feature {
|
||||
get { return new Feature() { Descriptor = new FeatureDescriptor() { Name = "Feature2" } }; }
|
||||
}
|
||||
|
||||
public int Create() {
|
||||
@@ -191,8 +193,8 @@ namespace Orchard.Tests.DataMigration {
|
||||
}
|
||||
|
||||
public class DataMigrationFeatureNeedUpdate3 : IDataMigration {
|
||||
public string Feature {
|
||||
get { return "Feature3"; }
|
||||
public Feature Feature {
|
||||
get { return new Feature() { Descriptor = new FeatureDescriptor() { Name = "Feature3" } }; }
|
||||
}
|
||||
|
||||
public int Create() {
|
||||
@@ -205,8 +207,8 @@ namespace Orchard.Tests.DataMigration {
|
||||
}
|
||||
|
||||
public class DataMigrationSimpleBuilder : DataMigrationImpl {
|
||||
public override string Feature {
|
||||
get { return "Feature1"; }
|
||||
public override Feature Feature {
|
||||
get { return new Feature() { Descriptor = new FeatureDescriptor() { Name = "Feature1" } }; }
|
||||
}
|
||||
|
||||
public int Create() {
|
||||
|
@@ -4,8 +4,8 @@ using Autofac;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Data;
|
||||
using Orchard.DataMigration.Interpreters;
|
||||
using Orchard.DataMigration.Schema;
|
||||
using Orchard.Data.Migration.Interpreters;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Tests.ContentManagement;
|
||||
using System.IO;
|
||||
|
@@ -1,7 +1,5 @@
|
||||
|
||||
using System;
|
||||
using Orchard.DataMigration.Interpreters;
|
||||
using Orchard.DataMigration.Schema;
|
||||
using Orchard.Data.Migration.Interpreters;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
|
||||
public class NullInterpreter : IDataMigrationInterpreter {
|
||||
|
||||
|
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Core.Common.DataMigrations {
|
||||
public class CommonDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Common_BodyRecord (Id INTEGER not null, Text TEXT, Format TEXT, ContentItemRecord_id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("BodyRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Text")
|
||||
.Column<string>("Format")
|
||||
.Column<int>("ContentItemRecord_id")
|
||||
);
|
||||
|
||||
//CREATE TABLE Common_CommonRecord (Id INTEGER not null, OwnerId INTEGER, CreatedUtc DATETIME, PublishedUtc DATETIME, ModifiedUtc DATETIME, Container_id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("CommonRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<int>("OwnerId")
|
||||
.Column<DateTime>("CreatedUtc")
|
||||
.Column<DateTime>("PublishedUtc")
|
||||
.Column<DateTime>("ModifiedUtc")
|
||||
.Column<int>("Container_id")
|
||||
);
|
||||
|
||||
//CREATE TABLE Common_CommonVersionRecord (Id INTEGER not null, CreatedUtc DATETIME, PublishedUtc DATETIME, ModifiedUtc DATETIME, ContentItemRecord_id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("CommonVersionRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<DateTime>("CreatedUtc")
|
||||
.Column<DateTime>("PublishedUtc")
|
||||
.Column<DateTime>("ModifiedUtc")
|
||||
.Column<int>("ContentItemRecord_id")
|
||||
);
|
||||
|
||||
//CREATE TABLE Common_RoutableRecord (Id INTEGER not null, Title TEXT, Slug TEXT, Path TEXT, ContentItemRecord_id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("RoutableRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Title")
|
||||
.Column<string>("Slug")
|
||||
.Column<string>("Path")
|
||||
.Column<int>("ContentItemRecord_id")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Core.Localization.DataMigrations {
|
||||
public class LocalizationDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Localization_LocalizedRecord (Id INTEGER not null, CultureId INTEGER, MasterContentItemId INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("LocalizedRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<int>("CultureId")
|
||||
.Column<int>("MasterContentItemId")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Core.Navigation.DataMigrations {
|
||||
public class NavigationDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Navigation_MenuItemRecord (Id INTEGER not null, Url TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("MenuItemRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Url")
|
||||
);
|
||||
|
||||
//CREATE TABLE Navigation_MenuPartRecord (Id INTEGER not null, MenuText TEXT, MenuPosition TEXT, OnMainMenu INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("MenuPartRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("MenuText")
|
||||
.Column<string>("MenuPosition")
|
||||
.Column<bool>("OnMainMenu")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -61,6 +61,7 @@
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Common\DataMigrations\CommonDataMigration.cs" />
|
||||
<Compile Include="Common\Drivers\BodyDriver.cs" />
|
||||
<Compile Include="Common\Drivers\CommonDriver.cs" />
|
||||
<Compile Include="Common\Drivers\RoutableDriver.cs" />
|
||||
@@ -76,7 +77,9 @@
|
||||
<Compile Include="Contents\ViewModels\EditItemViewModel.cs" />
|
||||
<Compile Include="Contents\ViewModels\ListContentsViewModel.cs" />
|
||||
<Compile Include="Contents\ViewModels\ListContentTypesViewModel.cs" />
|
||||
<Compile Include="Localization\DataMigrations\LocalizationDataMigration.cs" />
|
||||
<Compile Include="Localization\Drivers\LocalizedDriver.cs" />
|
||||
<Compile Include="Navigation\DataMigrations\NavigationDataMigration.cs" />
|
||||
<Compile Include="Routable\Controllers\ItemController.cs" />
|
||||
<Compile Include="Routable\Drivers\RoutableDriver.cs" />
|
||||
<Compile Include="Routable\Handlers\RoutableHandler.cs" />
|
||||
@@ -153,6 +156,7 @@
|
||||
<Compile Include="Routable\Services\RoutableService.cs" />
|
||||
<Compile Include="Routable\ViewModels\RoutableEditorViewModel.cs" />
|
||||
<Compile Include="Routable\ViewModels\RoutableDisplayViewModel.cs" />
|
||||
<Compile Include="Scheduling\DataMigrations\SchedulingDataMigration.cs" />
|
||||
<Compile Include="Scheduling\Models\ScheduledTaskRecord.cs" />
|
||||
<Compile Include="Scheduling\Services\PublishingTaskHandler.cs" />
|
||||
<Compile Include="Scheduling\Services\PublishingTaskManager.cs" />
|
||||
|
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Core.Scheduling.DataMigrations {
|
||||
public class SchedulingDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Scheduling_ScheduledTaskRecord (Id integer, TaskType TEXT, ScheduledUtc DATETIME, ContentItemVersionRecord_id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("ScheduledTaskRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("TaskType")
|
||||
.Column<DateTime>("ScheduledUtc")
|
||||
.Column<int>("ContentItemVersionRecord_id")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,28 +1,25 @@
|
||||
using Orchard.DataMigration;
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Core.Settings.DataMigrations {
|
||||
public class SettingsDataMigration : DataMigrationImpl {
|
||||
public override string Feature {
|
||||
get { return "Settings"; }
|
||||
}
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Settings_ContentFieldDefinitionRecord (Id integer, Name TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("Settings_ContentFieldDefinitionRecord", table => table
|
||||
SchemaBuilder.CreateTable("ContentFieldDefinitionRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Name")
|
||||
);
|
||||
|
||||
//CREATE TABLE Settings_ContentPartDefinitionRecord (Id integer, Name TEXT, Hidden INTEGER, Settings TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("Settings_ContentPartDefinitionRecord", table => table
|
||||
SchemaBuilder.CreateTable("ContentPartDefinitionRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Name")
|
||||
.Column<int>("Hidden")
|
||||
.Column<bool>("Hidden")
|
||||
.Column<string>("Settings")
|
||||
);
|
||||
|
||||
//CREATE TABLE Settings_ContentPartFieldDefinitionRecord (Id integer, Name TEXT, Settings TEXT, ContentFieldDefinitionRecord_id INTEGER, INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("Settings_ContentPartFieldDefinitionRecord", table => table
|
||||
SchemaBuilder.CreateTable("ContentPartFieldDefinitionRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Name")
|
||||
.Column<string>("Settings")
|
||||
@@ -31,16 +28,16 @@ namespace Orchard.Core.Settings.DataMigrations {
|
||||
);
|
||||
|
||||
//CREATE TABLE Settings_ContentTypeDefinitionRecord (Id integer, Name TEXT, DisplayName TEXT, Hidden INTEGER, Settings TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("Settings_ContentTypeDefinitionRecord", table => table
|
||||
SchemaBuilder.CreateTable("ContentTypeDefinitionRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Name")
|
||||
.Column<string>("DisplayName")
|
||||
.Column<int>("Hidden")
|
||||
.Column<bool>("Hidden")
|
||||
.Column<string>("Settings")
|
||||
);
|
||||
|
||||
//CREATE TABLE Settings_ContentTypePartDefinitionRecord (Id integer, Settings TEXT, ContentPartDefinitionRecord_id INTEGER, ContentTypeDefinitionRecord_Id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("Settings_ContentTypePartDefinitionRecord", table => table
|
||||
SchemaBuilder.CreateTable("ContentTypePartDefinitionRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Settings")
|
||||
.Column<int>("ContentPartDefinitionRecord_id")
|
||||
@@ -48,19 +45,19 @@ namespace Orchard.Core.Settings.DataMigrations {
|
||||
);
|
||||
|
||||
//CREATE TABLE Settings_ShellDescriptorRecord (Id integer, SerialNumber INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("Settings_ShellDescriptorRecord", table => table
|
||||
SchemaBuilder.CreateTable("ShellDescriptorRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<int>("SerialNumber")
|
||||
);
|
||||
|
||||
//CREATE TABLE Settings_ShellFeatureRecord (Id integer, Name TEXT, ShellDescriptorRecord_id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("Settings_ShellFeatureRecord", table => table
|
||||
SchemaBuilder.CreateTable("ShellFeatureRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Name")
|
||||
.Column<int>("ShellDescriptorRecord_id"));
|
||||
|
||||
//CREATE TABLE Settings_ShellFeatureStateRecord (Id integer, Name TEXT, InstallState TEXT, EnableState TEXT, ShellStateRecord_Id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("Settings_ShellFeatureStateRecord", table => table
|
||||
SchemaBuilder.CreateTable("ShellFeatureStateRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Name")
|
||||
.Column<string>("InstallState")
|
||||
@@ -69,7 +66,7 @@ namespace Orchard.Core.Settings.DataMigrations {
|
||||
);
|
||||
|
||||
//CREATE TABLE Settings_ShellParameterRecord (Id integer, Component TEXT, Name TEXT, Value TEXT, ShellDescriptorRecord_id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("Settings_ShellParameterRecord", table => table
|
||||
SchemaBuilder.CreateTable("ShellParameterRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Component")
|
||||
.Column<string>("Name")
|
||||
@@ -78,11 +75,22 @@ namespace Orchard.Core.Settings.DataMigrations {
|
||||
);
|
||||
|
||||
//CREATE TABLE Settings_ShellStateRecord (Id integer, primary key (Id));
|
||||
SchemaBuilder.CreateTable("Settings_ShellStateRecord", table => table
|
||||
SchemaBuilder.CreateTable("ShellStateRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Name")
|
||||
);
|
||||
|
||||
//CREATE TABLE Settings_SiteSettingsRecord (Id INTEGER not null, SiteSalt TEXT, SiteName TEXT, SuperUser TEXT, PageTitleSeparator TEXT, HomePage TEXT, SiteCulture TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("SiteSettingsRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("SiteSalt")
|
||||
.Column<string>("SiteName")
|
||||
.Column<string>("SuperUser")
|
||||
.Column<string>("PageTitleSeparator")
|
||||
.Column<string>("HomePage")
|
||||
.Column<string>("SiteCulture")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,23 @@
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Futures.Widgets.DataMigrations {
|
||||
public class WidgetsDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Futures_Widgets_HasWidgetsRecord (Id INTEGER not null, primary key (Id));
|
||||
SchemaBuilder.CreateTable("HasWidgetsRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
);
|
||||
|
||||
//CREATE TABLE Futures_Widgets_WidgetRecord (Id INTEGER not null, Zone TEXT, Position TEXT, Scope_id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("WidgetRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Zone")
|
||||
.Column<string>("Position")
|
||||
.Column<int>("Scope_id")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -59,6 +59,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Controllers\WidgetHandler.cs" />
|
||||
<Compile Include="DataMigrations\WidgetsDataMigration.cs" />
|
||||
<Compile Include="Models\HasWidgets.cs" />
|
||||
<Compile Include="Models\Widget.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
@@ -0,0 +1,26 @@
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Blogs.DataMigrations {
|
||||
public class BlogsDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Orchard_Blogs_BlogArchiveRecord (Id integer, Year INTEGER, Month INTEGER, PostCount INTEGER, Blog_id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("BlogArchiveRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<int>("Year")
|
||||
.Column<int>("Month")
|
||||
.Column<int>("PostCount")
|
||||
.Column<int>("Blog_id")
|
||||
);
|
||||
|
||||
//CREATE TABLE Orchard_Blogs_BlogRecord (Id INTEGER not null, Description TEXT, PostCount INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("BlogRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Description")
|
||||
.Column<int>("PostCount")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -68,6 +68,7 @@
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Commands\BlogCommands.cs" />
|
||||
<Compile Include="Controllers\BlogAdminController.cs" />
|
||||
<Compile Include="DataMigrations\BlogsDataMigration.cs" />
|
||||
<Compile Include="Drivers\BlogDriver.cs" />
|
||||
<Compile Include="Controllers\BlogPostAdminController.cs" />
|
||||
<Compile Include="Controllers\BlogPostController.cs" />
|
||||
|
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Comments.DataMigrations {
|
||||
public class CommentsDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Orchard_Comments_ClosedCommentsRecord (Id integer, ContentItemId INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("ClosedCommentsRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<int>("ContentItemId")
|
||||
);
|
||||
|
||||
//CREATE TABLE Orchard_Comments_CommentRecord (Id INTEGER not null, Author TEXT, SiteName TEXT, UserName TEXT, Email TEXT, Status TEXT, CommentDateUtc DATETIME, CommentText TEXT, CommentedOn INTEGER, CommentedOnContainer INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("CommentRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Author")
|
||||
.Column<string>("SiteName")
|
||||
.Column<string>("UserName")
|
||||
.Column<string>("Email")
|
||||
.Column<string>("Status")
|
||||
.Column<DateTime>("CommentDateUtc")
|
||||
.Column<string>("CommentText")
|
||||
.Column<int>("CommentedOn")
|
||||
.Column<int>("CommentedOnContainer")
|
||||
);
|
||||
|
||||
//CREATE TABLE Orchard_Comments_CommentSettingsRecord (Id INTEGER not null, ModerateComments INTEGER, EnableSpamProtection INTEGER, AkismetKey TEXT, AkismetUrl TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("CommentSettingsRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<bool>("ModerateComments")
|
||||
.Column<bool>("EnableSpamProtection")
|
||||
.Column<string>("AkismetKey")
|
||||
.Column<string>("AkismetUrl")
|
||||
);
|
||||
|
||||
//CREATE TABLE Orchard_Comments_HasCommentsRecord (Id INTEGER not null, CommentsShown INTEGER, CommentsActive INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("HasCommentsRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<bool>("CommentsShown")
|
||||
.Column<bool>("CommentsActive")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -72,6 +72,7 @@
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Controllers\CommentController.cs" />
|
||||
<Compile Include="DataMigrations\CommentsDataMigration.cs" />
|
||||
<Compile Include="Drivers\CommentDriver.cs" />
|
||||
<Compile Include="Drivers\HasCommentsContainerDriver.cs" />
|
||||
<Compile Include="Drivers\HasCommentsDriver.cs" />
|
||||
|
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Indexing.DataMigrations {
|
||||
public class IndexingDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
|
||||
SchemaBuilder.CreateTable("IndexingTaskRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<int>("Action")
|
||||
.Column<DateTime>("CreatedUtc")
|
||||
.Column<int>("ContentItemRecord_id")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -62,6 +62,7 @@
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Commands\IndexingCommands.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="DataMigrations\IndexingDataMigration.cs" />
|
||||
<Compile Include="Handlers\CreateIndexingTaskHandler.cs" />
|
||||
<Compile Include="Models\IndexingTask.cs" />
|
||||
<Compile Include="Models\IndexingTaskRecord.cs" />
|
||||
|
@@ -0,0 +1,16 @@
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Media.DataMigrations {
|
||||
public class MediaDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Orchard_Media_MediaSettingsRecord (Id INTEGER not null, RootMediaFolder TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("MediaSettingsRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("RootMediaFolder")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -71,6 +71,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="DataMigrations\MediaDataMigration.cs" />
|
||||
<Compile Include="Helpers\MediaHelpers.cs" />
|
||||
<Compile Include="Models\MediaSettings.cs" />
|
||||
<Compile Include="Handlers\MediaSettingsHandler.cs" />
|
||||
|
@@ -0,0 +1,39 @@
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Roles.DataMigrations {
|
||||
public class RolesDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Orchard_Roles_PermissionRecord (Id integer, Name TEXT, ModuleName TEXT, Description TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("PermissionRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Name")
|
||||
.Column<string>("ModuleName")
|
||||
.Column<string>("Description")
|
||||
);
|
||||
|
||||
//CREATE TABLE Orchard_Roles_RoleRecord (Id integer, Name TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("RoleRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Name")
|
||||
);
|
||||
|
||||
//CREATE TABLE Orchard_Roles_RolesPermissionsRecord (Id integer, Role_id INTEGER, Permission_id INTEGER, RoleRecord_Id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("RolesPermissionsRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<int>("Role_id")
|
||||
.Column<int>("Permission_id")
|
||||
.Column<int>("RoleRecord_Id")
|
||||
);
|
||||
|
||||
//CREATE TABLE Orchard_Roles_UserRolesRecord (Id integer, UserId INTEGER, Role_id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("UserRolesRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<int>("UserId")
|
||||
.Column<int>("Role_id")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -67,6 +67,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="DataMigrations\RolesDataMigration.cs" />
|
||||
<Compile Include="Drivers\UserRolesDriver.cs" />
|
||||
<Compile Include="DefaultRoleUpdater.cs" />
|
||||
<Compile Include="Models\IUserRoles.cs" />
|
||||
|
@@ -0,0 +1,20 @@
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Sandbox.DataMigrations {
|
||||
public class SandboxDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
SchemaBuilder.CreateTable("SandboxPageRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Name")
|
||||
);
|
||||
|
||||
SchemaBuilder.CreateTable("SandboxSettingsRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<bool>("AllowAnonymousEdits")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -67,6 +67,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\PageController.cs" />
|
||||
<Compile Include="DataMigrations\SandBoxDataMigration.cs" />
|
||||
<Compile Include="Drivers\SandboxPageDriver.cs" />
|
||||
<Compile Include="Models\SandboxPage.cs" />
|
||||
<Compile Include="Handlers\SandboxContentHandler.cs" />
|
||||
|
@@ -0,0 +1,17 @@
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Search.DataMigrations {
|
||||
public class SearchDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
|
||||
SchemaBuilder.CreateTable("SearchSettingsRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<bool>("FilterCulture")
|
||||
.Column<string>("SearchedFields")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -66,6 +66,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers\SearchController.cs" />
|
||||
<Compile Include="DataMigrations\SearchDataMigration.cs" />
|
||||
<Compile Include="Filters\SearchFilter.cs" />
|
||||
<Compile Include="Models\SearchSettings.cs" />
|
||||
<Compile Include="Models\SearchSettingsRecord.cs" />
|
||||
|
@@ -8,9 +8,9 @@ using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Navigation.Models;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Data.Migration.Interpreters;
|
||||
using Orchard.Data.Providers;
|
||||
using Orchard.DataMigration.Interpreters;
|
||||
using Orchard.DataMigration.Schema;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
@@ -23,7 +23,7 @@ using Orchard.Settings;
|
||||
using Orchard.Themes;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Environment.State;
|
||||
using Orchard.DataMigration;
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Setup.Services {
|
||||
public class SetupService : ISetupService {
|
||||
@@ -114,6 +114,7 @@ namespace Orchard.Setup.Services {
|
||||
.Column<int>("Current"));
|
||||
|
||||
var dataMigrationManager = environment.Resolve<IDataMigrationManager>();
|
||||
dataMigrationManager.Update("Orchard.Framework");
|
||||
dataMigrationManager.Update("Settings");
|
||||
|
||||
environment.Resolve<IShellDescriptorManager>().UpdateShellDescriptor(
|
||||
|
@@ -8,9 +8,9 @@ using Orchard.Commands.Builtin;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
using Orchard.Data.Migration.Interpreters;
|
||||
using Orchard.Data.Providers;
|
||||
using Orchard.DataMigration;
|
||||
using Orchard.DataMigration.Interpreters;
|
||||
using Orchard.Data.Migration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Mvc;
|
||||
|
@@ -0,0 +1,23 @@
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Tags.DataMigrations {
|
||||
public class TagsDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Orchard_Tags_Tag (Id integer, TagName TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("Tag", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("TagName")
|
||||
);
|
||||
|
||||
//CREATE TABLE Orchard_Tags_TagsContentItems (Id integer, TagId INTEGER, ContentItemId INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("TagsContentItems", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<int>("TagId")
|
||||
.Column<int>("ContentItemId")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -67,6 +67,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="DataMigrations\TagsDataMigration.cs" />
|
||||
<Compile Include="Models\TagsContentItems.cs" />
|
||||
<Compile Include="Services\ITagService.cs" />
|
||||
<Compile Include="ViewModels\EditTagsViewModel.cs" />
|
||||
|
@@ -0,0 +1,28 @@
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Themes.DataMigrations {
|
||||
public class ThemesDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Orchard_Themes_ThemeRecord (Id INTEGER not null, ThemeName TEXT, DisplayName TEXT, Description TEXT, Version TEXT, Author TEXT, HomePage TEXT, Tags TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("ThemeRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("ThemeName")
|
||||
.Column<string>("DisplayName")
|
||||
.Column<string>("Description")
|
||||
.Column<string>("Version")
|
||||
.Column<string>("Author")
|
||||
.Column<string>("HomePage")
|
||||
.Column<string>("Tags")
|
||||
);
|
||||
|
||||
//CREATE TABLE Orchard_Themes_ThemeSiteSettingsRecord (Id INTEGER not null, CurrentThemeName TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("ThemeSiteSettingsRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("CurrentThemeName")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -67,6 +67,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="DataMigrations\ThemesDataMigration.cs" />
|
||||
<Compile Include="DesignerNotes\ZoneManagerEvents.cs" />
|
||||
<Compile Include="Handlers\ThemeSiteSettingsHandler.cs" />
|
||||
<Compile Include="Models\Theme.cs" />
|
||||
|
@@ -0,0 +1,22 @@
|
||||
using Orchard.Data.Migration;
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Users.DataMigrations {
|
||||
public class UsersDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Orchard_Users_UserRecord (Id INTEGER not null, UserName TEXT, Email TEXT, NormalizedUserName TEXT, Password TEXT, PasswordFormat TEXT, PasswordSalt TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("UserRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("UserName")
|
||||
.Column<string>("Email")
|
||||
.Column<string>("NormalizedUserName")
|
||||
.Column<string>("Password")
|
||||
.Column<string>("PasswordFormat")
|
||||
.Column<string>("PasswordSalt")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -67,6 +67,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers\AccountController.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="DataMigrations\UsersDataMigration.cs" />
|
||||
<Compile Include="Drivers\UserDriver.cs" />
|
||||
<Compile Include="Models\User.cs" />
|
||||
<Compile Include="Handlers\UserHandler.cs" />
|
||||
|
@@ -0,0 +1,41 @@
|
||||
using Orchard.Data.Migration;
|
||||
using Orchard.Data.Migration;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.ContentManagement.DataMigrations {
|
||||
public class FrameworkDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Orchard_Framework_ContentItemRecord (Id integer, Data TEXT, ContentType_id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("ContentItemRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Data")
|
||||
.Column<int>("ContentType_id")
|
||||
);
|
||||
|
||||
//CREATE TABLE Orchard_Framework_ContentItemVersionRecord (Id integer, Number INTEGER, Published INTEGER, Latest INTEGER, Data TEXT, ContentItemRecord_id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("ContentItemVersionRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<int>("Number")
|
||||
.Column<bool>("Published")
|
||||
.Column<bool>("Latest")
|
||||
.Column<string>("Data")
|
||||
.Column<int>("ContentItemRecord_id")
|
||||
);
|
||||
|
||||
//CREATE TABLE Orchard_Framework_ContentTypeRecord (Id integer, Name TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("ContentTypeRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Name")
|
||||
);
|
||||
|
||||
//CREATE TABLE Orchard_Framework_CultureRecord (Id integer, Culture TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("CultureRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
.Column<string>("Culture")
|
||||
);
|
||||
|
||||
return 0010;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,3 @@
|
||||
using System;
|
||||
using Orchard.ContentManagement.FieldStorage;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
|
||||
namespace Orchard.ContentManagement.Records {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Orchard.Commands;
|
||||
|
||||
namespace Orchard.DataMigration.Commands {
|
||||
namespace Orchard.Data.Migration.Commands {
|
||||
public class DataMigrationCommands : DefaultOrchardCommandHandler {
|
||||
private readonly IDataMigrationManager _dataMigrationManager;
|
||||
|
@@ -1,11 +1,13 @@
|
||||
using Orchard.DataMigration.Schema;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.DataMigration {
|
||||
namespace Orchard.Data.Migration {
|
||||
/// <summary>
|
||||
/// Data Migration classes can inherit from this class to get a SchemaBuilder instance configured with the current tenant database prefix
|
||||
/// </summary>
|
||||
public abstract class DataMigrationImpl : IDataMigration {
|
||||
public abstract string Feature { get; }
|
||||
public SchemaBuilder SchemaBuilder { get; set; }
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.DataMigration {
|
||||
namespace Orchard.Data.Migration {
|
||||
/// <summary>
|
||||
/// Responsible for executing data migration tasks when a feature is enabled for the first time
|
||||
/// 1) Initial install of a module:
|
@@ -3,16 +3,14 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Orchard.Data;
|
||||
using Orchard.Data.Providers;
|
||||
using Orchard.DataMigration.Interpreters;
|
||||
using Orchard.DataMigration.Schema;
|
||||
using Orchard.Data.Migration.Interpreters;
|
||||
using Orchard.Data.Migration.Records;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.State;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
|
||||
namespace Orchard.DataMigration {
|
||||
namespace Orchard.Data.Migration {
|
||||
/// <summary>
|
||||
/// Reponsible for maintaining the knowledge of data migration in a per tenant table
|
||||
/// </summary>
|
||||
@@ -56,7 +54,7 @@ namespace Orchard.DataMigration {
|
||||
|
||||
// try to resolve a Create method
|
||||
if ( GetCreateMethod(dataMigration) != null ) {
|
||||
features.Add(dataMigration.Feature);
|
||||
features.Add(dataMigration.Feature.Descriptor.Name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -64,7 +62,7 @@ namespace Orchard.DataMigration {
|
||||
var lookupTable = CreateUpgradeLookupTable(dataMigration);
|
||||
|
||||
if(lookupTable.ContainsKey(current)) {
|
||||
features.Add(dataMigration.Feature);
|
||||
features.Add(dataMigration.Feature.Descriptor.Name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +170,6 @@ namespace Orchard.DataMigration {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private DataMigrationRecord GetDataMigrationRecord(IDataMigration tempMigration) {
|
||||
return _dataMigrationRepository.Table
|
||||
.Where(dm => dm.DataMigrationClass == tempMigration.GetType().FullName)
|
||||
@@ -184,11 +181,11 @@ namespace Orchard.DataMigration {
|
||||
/// </summary>
|
||||
private IEnumerable<IDataMigration> GetDataMigrations(string feature) {
|
||||
var migrations = _dataMigrations
|
||||
.Where(dm => String.Equals(dm.Feature, feature, StringComparison.OrdinalIgnoreCase))
|
||||
.Where(dm => String.Equals(dm.Feature.Descriptor.Name, feature, StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
|
||||
foreach (var migration in migrations.OfType<DataMigrationImpl>()) {
|
||||
migration.SchemaBuilder = new SchemaBuilder(_interpreter);
|
||||
migration.SchemaBuilder = new SchemaBuilder(_interpreter, migration.Feature.Descriptor.Name.Replace(".", "_") + "_");
|
||||
}
|
||||
|
||||
return migrations;
|
@@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.DataMigration.Schema;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
|
||||
namespace Orchard.DataMigration {
|
||||
namespace Orchard.Data.Migration {
|
||||
public class DefaultDataMigrationGenerator : IDataMigrationGenerator {
|
||||
public IEnumerable<ISchemaBuilderCommand> CreateCommands(IEnumerable<RecordBlueprint> records) {
|
||||
|
7
src/Orchard/Data/Migration/IDataMigration.cs
Normal file
7
src/Orchard/Data/Migration/IDataMigration.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Data.Migration {
|
||||
public interface IDataMigration : IDependency {
|
||||
Feature Feature { get; }
|
||||
}
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using FluentNHibernate.Cfg;
|
||||
using Orchard.DataMigration.Schema;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
|
||||
namespace Orchard.DataMigration {
|
||||
namespace Orchard.Data.Migration {
|
||||
// Builds and runs the representative migration create calls
|
||||
public interface IDataMigrationGenerator : IDependency {
|
||||
IEnumerable<ISchemaBuilderCommand> CreateCommands(IEnumerable<RecordBlueprint> records);
|
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.DataMigration {
|
||||
namespace Orchard.Data.Migration {
|
||||
public interface IDataMigrationManager : IDependency {
|
||||
/// <summary>
|
||||
/// Whether a feature has already been installed, i.e. one of its Data Migration class has already been processed
|
@@ -6,12 +6,11 @@ using System.Text;
|
||||
using NHibernate;
|
||||
using NHibernate.Dialect;
|
||||
using NHibernate.SqlTypes;
|
||||
using Orchard.Data;
|
||||
using Orchard.DataMigration.Schema;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Logging;
|
||||
|
||||
namespace Orchard.DataMigration.Interpreters {
|
||||
namespace Orchard.Data.Migration.Interpreters {
|
||||
public class DefaultDataMigrationInterpreter : IDataMigrationInterpreter {
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly IEnumerable<ICommandInterpreter> _commandInterpreters;
|
@@ -1,6 +1,6 @@
|
||||
using Orchard.DataMigration.Schema;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
|
||||
namespace Orchard.DataMigration.Interpreters {
|
||||
namespace Orchard.Data.Migration.Interpreters {
|
||||
/// <summary>
|
||||
/// This interface can be implemented to provide a data migration behavior
|
||||
/// </summary>
|
@@ -1,6 +1,6 @@
|
||||
using Orchard.DataMigration.Schema;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
|
||||
namespace Orchard.DataMigration.Interpreters {
|
||||
namespace Orchard.Data.Migration.Interpreters {
|
||||
public interface IDataMigrationInterpreter : IDependency{
|
||||
void Visit(ISchemaBuilderCommand command);
|
||||
void Visit(CreateTableCommand command);
|
@@ -1,14 +1,14 @@
|
||||
using Orchard.DataMigration.Schema;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
|
||||
namespace Orchard.DataMigration.Interpreters {
|
||||
public class SqLiteCommandInterpreter :
|
||||
namespace Orchard.Data.Migration.Interpreters {
|
||||
public class SqLiteCommandInterpreter :
|
||||
ICommandInterpreter<DropColumnCommand>,
|
||||
ICommandInterpreter<AlterColumnCommand>,
|
||||
ICommandInterpreter<AlterColumnCommand>,
|
||||
ICommandInterpreter<CreateForeignKeyCommand>,
|
||||
ICommandInterpreter<DropForeignKeyCommand>,
|
||||
ICommandInterpreter<AddIndexCommand>,
|
||||
ICommandInterpreter<DropIndexCommand> {
|
||||
|
||||
|
||||
public string[] CreateStatements(DropColumnCommand command) {
|
||||
return new string[0];
|
||||
}
|
||||
@@ -36,5 +36,5 @@ namespace Orchard.DataMigration.Interpreters {
|
||||
public string DataProvider {
|
||||
get { return "SQLite"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.DataMigration {
|
||||
namespace Orchard.Data.Migration.Records {
|
||||
public class DataMigrationRecord {
|
||||
public virtual int Id { get; set; }
|
||||
public virtual string DataMigrationClass { get; set; }
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class AddColumnCommand : CreateColumnCommand {
|
||||
public AddColumnCommand(string tableName, string name) : base(tableName, name) {
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class AddIndexCommand : TableCommand {
|
||||
public string IndexName { get; set; }
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using System.Data;
|
||||
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class AlterColumnCommand : ColumnCommand {
|
||||
public AlterColumnCommand(string tableName, string columnName)
|
||||
: base(tableName, columnName) {
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class AlterTableCommand : SchemaCommand {
|
||||
public AlterTableCommand(string name)
|
||||
: base(name, SchemaCommandType.AlterTable) {
|
@@ -1,6 +1,6 @@
|
||||
using System.Data;
|
||||
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class ColumnCommand : TableCommand {
|
||||
public string ColumnName { get; set; }
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using System.Data;
|
||||
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class CreateColumnCommand : ColumnCommand {
|
||||
public CreateColumnCommand(string tableName, string name) : base(tableName, name) {
|
||||
IsNotNull = false;
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class CreateForeignKeyCommand : SchemaCommand {
|
||||
|
||||
public string[] DestColumns { get; private set; }
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class CreateTableCommand : SchemaCommand {
|
||||
public CreateTableCommand(string name)
|
||||
: base(name, SchemaCommandType.CreateTable) {
|
||||
@@ -24,9 +24,15 @@ namespace Orchard.DataMigration.Schema {
|
||||
case TypeCode.String :
|
||||
dbType = DbType.String;
|
||||
break;
|
||||
case TypeCode.Int32 :
|
||||
case TypeCode.Int32:
|
||||
dbType = DbType.Int32;
|
||||
break;
|
||||
case TypeCode.DateTime:
|
||||
dbType = DbType.DateTime;
|
||||
break;
|
||||
case TypeCode.Boolean:
|
||||
dbType = DbType.Boolean;
|
||||
break;
|
||||
default:
|
||||
Enum.TryParse(System.Type.GetTypeCode(typeof (T)).ToString(), true, out dbType);
|
||||
break;
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class DropColumnCommand : ColumnCommand {
|
||||
|
||||
public DropColumnCommand(string tableName, string columnName)
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class DropForeignKeyCommand : SchemaCommand {
|
||||
public string SrcTable { get; private set; }
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class DropIndexCommand : TableCommand {
|
||||
public string IndexName { get; set; }
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class DropTableCommand : SchemaCommand {
|
||||
public DropTableCommand(string name)
|
||||
: base(name, SchemaCommandType.DropTable) {
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public interface ISchemaBuilderCommand {
|
||||
}
|
||||
}
|
@@ -1,35 +1,32 @@
|
||||
using System;
|
||||
using Orchard.DataMigration.Interpreters;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
using Orchard.Data.Migration.Interpreters;
|
||||
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class SchemaBuilder {
|
||||
private readonly IDataMigrationInterpreter _interpreter;
|
||||
|
||||
public SchemaBuilder(IDataMigrationInterpreter interpreter) {
|
||||
private readonly string _featurePrefix;
|
||||
|
||||
public SchemaBuilder(IDataMigrationInterpreter interpreter, string featurePrefix = null) {
|
||||
_interpreter = interpreter;
|
||||
_featurePrefix = featurePrefix;
|
||||
}
|
||||
|
||||
public SchemaBuilder CreateTable(string name, Action<CreateTableCommand> table) {
|
||||
var createTable = new CreateTableCommand(name);
|
||||
var createTable = new CreateTableCommand(String.Concat(_featurePrefix, name));
|
||||
table(createTable);
|
||||
Run(createTable);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SchemaBuilder CreateTable<TRecord>(Action<CreateTableCommand> table) {
|
||||
return CreateTable(typeof (TRecord).FullName.Replace(".", "_"), table);
|
||||
}
|
||||
|
||||
public SchemaBuilder AlterTable(string name, Action<AlterTableCommand> table) {
|
||||
var alterTable = new AlterTableCommand(name);
|
||||
var alterTable = new AlterTableCommand(String.Concat(_featurePrefix, name));
|
||||
table(alterTable);
|
||||
Run(alterTable);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SchemaBuilder DropTable(string name) {
|
||||
var deleteTable = new DropTableCommand(name);
|
||||
var deleteTable = new DropTableCommand(String.Concat(_featurePrefix, name));
|
||||
Run(deleteTable);
|
||||
return this;
|
||||
}
|
||||
@@ -43,18 +40,18 @@ namespace Orchard.DataMigration.Schema {
|
||||
return this;
|
||||
}
|
||||
|
||||
private void Run(SchemaCommand command) {
|
||||
private void Run(ISchemaBuilderCommand command) {
|
||||
_interpreter.Visit(command);
|
||||
}
|
||||
|
||||
public SchemaBuilder CreateForeignKey(string name, string srcTable, string[] srcColumns, string destTable, string[] destColumns) {
|
||||
var command = new CreateForeignKeyCommand(name, srcTable, srcColumns, destTable, destColumns);
|
||||
var command = new CreateForeignKeyCommand(name, String.Concat(_featurePrefix, srcTable), srcColumns, String.Concat(_featurePrefix, destTable), destColumns);
|
||||
Run(command);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SchemaBuilder DropForeignKey(string srcTable, string name) {
|
||||
var command = new DropForeignKeyCommand(srcTable, name);
|
||||
var command = new DropForeignKeyCommand(String.Concat(_featurePrefix, srcTable), name);
|
||||
Run(command);
|
||||
return this;
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public abstract class SchemaCommand : ISchemaBuilderCommand {
|
||||
protected SchemaCommand(string name, SchemaCommandType type ) {
|
||||
TableCommands = new List<TableCommand>();
|
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class SqlStatementCommand : SchemaCommand {
|
||||
protected readonly List<string> _providers;
|
||||
public SqlStatementCommand(string sql)
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.DataMigration.Schema {
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class TableCommand : ISchemaBuilderCommand{
|
||||
public string TableName { get; private set; }
|
||||
|
@@ -1,5 +0,0 @@
|
||||
namespace Orchard.DataMigration {
|
||||
public interface IDataMigration : IDependency {
|
||||
string Feature { get; }
|
||||
}
|
||||
}
|
@@ -356,37 +356,38 @@
|
||||
<Compile Include="ContentManagement\ViewModels\TemplateViewModel.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DataMigration\Interpreters\ICommandInterpreter.cs" />
|
||||
<Compile Include="DataMigration\Interpreters\DefaultDataMigrationInterpreter.cs" />
|
||||
<Compile Include="DataMigration\Interpreters\IDataMigrationInterpreter.cs" />
|
||||
<Compile Include="DataMigration\Interpreters\SqLiteCommandInterpreter.cs" />
|
||||
<Compile Include="DataMigration\Schema\AddColumnCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\ISchemaBuilderCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\IShellSettings.cs" />
|
||||
<Compile Include="DataMigration\Schema\SqlStatementCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\CreateColumnCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\CreateForeignKeyCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\DropForeignKeyCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\DropIndexCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\AddIndexCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\DropColumnCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\AlterColumnCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\DropTableCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\AlterTableCommand.cs" />
|
||||
<Compile Include="DataMigration\Commands\DataMigrationCommands.cs" />
|
||||
<Compile Include="DataMigration\Schema\SchemaBuilder.cs" />
|
||||
<Compile Include="DataMigration\DataMigrationCoordinator.cs" />
|
||||
<Compile Include="DataMigration\DefaultDataMigrationGenerator.cs" />
|
||||
<Compile Include="DataMigration\IDataMigrationGenerator.cs" />
|
||||
<Compile Include="DataMigration\DataMigration.cs" />
|
||||
<Compile Include="DataMigration\DataMigrationManager.cs" />
|
||||
<Compile Include="DataMigration\DataMigrationRecord.cs" />
|
||||
<Compile Include="DataMigration\IDataMigration.cs" />
|
||||
<Compile Include="DataMigration\IDataMigrationManager.cs" />
|
||||
<Compile Include="DataMigration\Schema\ColumnCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\CreateTableCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\TableCommand.cs" />
|
||||
<Compile Include="DataMigration\Schema\SchemaCommand.cs" />
|
||||
<Compile Include="ContentManagement\DataMigrations\FrameworkDataMigration.cs" />
|
||||
<Compile Include="Data\Migration\Interpreters\ICommandInterpreter.cs" />
|
||||
<Compile Include="Data\Migration\Interpreters\DefaultDataMigrationInterpreter.cs" />
|
||||
<Compile Include="Data\Migration\Interpreters\IDataMigrationInterpreter.cs" />
|
||||
<Compile Include="Data\Migration\Interpreters\SqLiteCommandInterpreter.cs" />
|
||||
<Compile Include="Data\Migration\Schema\AddColumnCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\ISchemaBuilderCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\IShellSettings.cs" />
|
||||
<Compile Include="Data\Migration\Schema\SqlStatementCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\CreateColumnCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\CreateForeignKeyCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\DropForeignKeyCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\DropIndexCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\AddIndexCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\DropColumnCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\AlterColumnCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\DropTableCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\AlterTableCommand.cs" />
|
||||
<Compile Include="Data\Migration\Commands\DataMigrationCommands.cs" />
|
||||
<Compile Include="Data\Migration\Schema\SchemaBuilder.cs" />
|
||||
<Compile Include="Data\Migration\DataMigrationCoordinator.cs" />
|
||||
<Compile Include="Data\Migration\DefaultDataMigrationGenerator.cs" />
|
||||
<Compile Include="Data\Migration\IDataMigrationGenerator.cs" />
|
||||
<Compile Include="Data\Migration\DataMigration.cs" />
|
||||
<Compile Include="Data\Migration\DataMigrationManager.cs" />
|
||||
<Compile Include="Data\Migration\Records\DataMigrationRecord.cs" />
|
||||
<Compile Include="Data\Migration\IDataMigration.cs" />
|
||||
<Compile Include="Data\Migration\IDataMigrationManager.cs" />
|
||||
<Compile Include="Data\Migration\Schema\ColumnCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\CreateTableCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\TableCommand.cs" />
|
||||
<Compile Include="Data\Migration\Schema\SchemaCommand.cs" />
|
||||
<Compile Include="Data\Providers\DataServiceParameters.cs" />
|
||||
<Compile Include="Data\Providers\IDataServicesProvider.cs" />
|
||||
<Compile Include="Data\Providers\SessionFactoryParameters.cs" />
|
||||
|
Reference in New Issue
Block a user