diff --git a/src/Orchard.Tests/DataMigration/DataMigrationTests.cs b/src/Orchard.Tests/DataMigration/DataMigrationTests.cs index f1d88760e..bc3c89cc2 100644 --- a/src/Orchard.Tests/DataMigration/DataMigrationTests.cs +++ b/src/Orchard.Tests/DataMigration/DataMigrationTests.cs @@ -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() { diff --git a/src/Orchard.Tests/DataMigration/SchemaBuilderTests.cs b/src/Orchard.Tests/DataMigration/SchemaBuilderTests.cs index 3d734edba..2053bffc1 100644 --- a/src/Orchard.Tests/DataMigration/SchemaBuilderTests.cs +++ b/src/Orchard.Tests/DataMigration/SchemaBuilderTests.cs @@ -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; diff --git a/src/Orchard.Tests/DataMigration/Utilities/NullInterpreter.cs b/src/Orchard.Tests/DataMigration/Utilities/NullInterpreter.cs index 9887aa4fc..6e87a8f40 100644 --- a/src/Orchard.Tests/DataMigration/Utilities/NullInterpreter.cs +++ b/src/Orchard.Tests/DataMigration/Utilities/NullInterpreter.cs @@ -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 { diff --git a/src/Orchard.Web/Core/Common/DataMigrations/CommonDataMigration.cs b/src/Orchard.Web/Core/Common/DataMigrations/CommonDataMigration.cs new file mode 100644 index 000000000..f1fa72627 --- /dev/null +++ b/src/Orchard.Web/Core/Common/DataMigrations/CommonDataMigration.cs @@ -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("Id", column => column.PrimaryKey()) + .Column("Text") + .Column("Format") + .Column("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("Id", column => column.PrimaryKey()) + .Column("OwnerId") + .Column("CreatedUtc") + .Column("PublishedUtc") + .Column("ModifiedUtc") + .Column("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("Id", column => column.PrimaryKey()) + .Column("CreatedUtc") + .Column("PublishedUtc") + .Column("ModifiedUtc") + .Column("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("Id", column => column.PrimaryKey()) + .Column("Title") + .Column("Slug") + .Column("Path") + .Column("ContentItemRecord_id") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Localization/DataMigrations/LocalizationDataMigration.cs b/src/Orchard.Web/Core/Localization/DataMigrations/LocalizationDataMigration.cs new file mode 100644 index 000000000..1eed07b70 --- /dev/null +++ b/src/Orchard.Web/Core/Localization/DataMigrations/LocalizationDataMigration.cs @@ -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("Id", column => column.PrimaryKey()) + .Column("CultureId") + .Column("MasterContentItemId") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Navigation/DataMigrations/NavigationDataMigration.cs b/src/Orchard.Web/Core/Navigation/DataMigrations/NavigationDataMigration.cs new file mode 100644 index 000000000..2910c823b --- /dev/null +++ b/src/Orchard.Web/Core/Navigation/DataMigrations/NavigationDataMigration.cs @@ -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("Id", column => column.PrimaryKey()) + .Column("Url") + ); + + //CREATE TABLE Navigation_MenuPartRecord (Id INTEGER not null, MenuText TEXT, MenuPosition TEXT, OnMainMenu INTEGER, primary key (Id)); + SchemaBuilder.CreateTable("MenuPartRecord", table => table + .Column("Id", column => column.PrimaryKey()) + .Column("MenuText") + .Column("MenuPosition") + .Column("OnMainMenu") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj index a70ca21c0..0a234eab9 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -61,6 +61,7 @@ + @@ -76,7 +77,9 @@ + + @@ -153,6 +156,7 @@ + diff --git a/src/Orchard.Web/Core/Scheduling/DataMigrations/SchedulingDataMigration.cs b/src/Orchard.Web/Core/Scheduling/DataMigrations/SchedulingDataMigration.cs new file mode 100644 index 000000000..2cea744d1 --- /dev/null +++ b/src/Orchard.Web/Core/Scheduling/DataMigrations/SchedulingDataMigration.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("Id", column => column.PrimaryKey()) + .Column("TaskType") + .Column("ScheduledUtc") + .Column("ContentItemVersionRecord_id") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Settings/DataMigrations/SettingsDataMigration.cs b/src/Orchard.Web/Core/Settings/DataMigrations/SettingsDataMigration.cs index eba65db7c..2116c1ca8 100644 --- a/src/Orchard.Web/Core/Settings/DataMigrations/SettingsDataMigration.cs +++ b/src/Orchard.Web/Core/Settings/DataMigrations/SettingsDataMigration.cs @@ -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("Id", column => column.PrimaryKey()) .Column("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("Id", column => column.PrimaryKey()) .Column("Name") - .Column("Hidden") + .Column("Hidden") .Column("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("Id", column => column.PrimaryKey()) .Column("Name") .Column("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("Id", column => column.PrimaryKey()) .Column("Name") .Column("DisplayName") - .Column("Hidden") + .Column("Hidden") .Column("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("Id", column => column.PrimaryKey()) .Column("Settings") .Column("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("Id", column => column.PrimaryKey()) .Column("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("Id", column => column.PrimaryKey()) .Column("Name") .Column("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("Id", column => column.PrimaryKey()) .Column("Name") .Column("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("Id", column => column.PrimaryKey()) .Column("Component") .Column("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("Id", column => column.PrimaryKey()) .Column("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("Id", column => column.PrimaryKey()) + .Column("SiteSalt") + .Column("SiteName") + .Column("SuperUser") + .Column("PageTitleSeparator") + .Column("HomePage") + .Column("SiteCulture") + ); + return 0010; } } diff --git a/src/Orchard.Web/Modules/Futures.Widgets/DataMigrations/WidgetsDataMigration.cs b/src/Orchard.Web/Modules/Futures.Widgets/DataMigrations/WidgetsDataMigration.cs new file mode 100644 index 000000000..6e06cd0ae --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/DataMigrations/WidgetsDataMigration.cs @@ -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("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("Id", column => column.PrimaryKey()) + .Column("Zone") + .Column("Position") + .Column("Scope_id") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Futures.Widgets.csproj b/src/Orchard.Web/Modules/Futures.Widgets/Futures.Widgets.csproj index b4442b16c..290b659e8 100644 --- a/src/Orchard.Web/Modules/Futures.Widgets/Futures.Widgets.csproj +++ b/src/Orchard.Web/Modules/Futures.Widgets/Futures.Widgets.csproj @@ -59,6 +59,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/DataMigrations/BlogsDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Blogs/DataMigrations/BlogsDataMigration.cs new file mode 100644 index 000000000..8756eb989 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Blogs/DataMigrations/BlogsDataMigration.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("Id", column => column.PrimaryKey()) + .Column("Year") + .Column("Month") + .Column("PostCount") + .Column("Blog_id") + ); + + //CREATE TABLE Orchard_Blogs_BlogRecord (Id INTEGER not null, Description TEXT, PostCount INTEGER, primary key (Id)); + SchemaBuilder.CreateTable("BlogRecord", table => table + .Column("Id", column => column.PrimaryKey()) + .Column("Description") + .Column("PostCount") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Orchard.Blogs.csproj b/src/Orchard.Web/Modules/Orchard.Blogs/Orchard.Blogs.csproj index a27f9f0af..5016b362b 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Orchard.Blogs.csproj +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Orchard.Blogs.csproj @@ -68,6 +68,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Comments/DataMigrations/CommentsDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Comments/DataMigrations/CommentsDataMigration.cs new file mode 100644 index 000000000..7b7f1d689 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Comments/DataMigrations/CommentsDataMigration.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("Id", column => column.PrimaryKey()) + .Column("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("Id", column => column.PrimaryKey()) + .Column("Author") + .Column("SiteName") + .Column("UserName") + .Column("Email") + .Column("Status") + .Column("CommentDateUtc") + .Column("CommentText") + .Column("CommentedOn") + .Column("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("Id", column => column.PrimaryKey()) + .Column("ModerateComments") + .Column("EnableSpamProtection") + .Column("AkismetKey") + .Column("AkismetUrl") + ); + + //CREATE TABLE Orchard_Comments_HasCommentsRecord (Id INTEGER not null, CommentsShown INTEGER, CommentsActive INTEGER, primary key (Id)); + SchemaBuilder.CreateTable("HasCommentsRecord", table => table + .Column("Id", column => column.PrimaryKey()) + .Column("CommentsShown") + .Column("CommentsActive") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Orchard.Comments.csproj b/src/Orchard.Web/Modules/Orchard.Comments/Orchard.Comments.csproj index 391eb11c5..5291a071d 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Orchard.Comments.csproj +++ b/src/Orchard.Web/Modules/Orchard.Comments/Orchard.Comments.csproj @@ -72,6 +72,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Indexing/DataMigrations/IndexingDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Indexing/DataMigrations/IndexingDataMigration.cs new file mode 100644 index 000000000..c1c11bd9d --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Indexing/DataMigrations/IndexingDataMigration.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("Id", column => column.PrimaryKey()) + .Column("Action") + .Column("CreatedUtc") + .Column("ContentItemRecord_id") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Indexing/Orchard.Indexing.csproj b/src/Orchard.Web/Modules/Orchard.Indexing/Orchard.Indexing.csproj index 179e2bb84..bd3bd046c 100644 --- a/src/Orchard.Web/Modules/Orchard.Indexing/Orchard.Indexing.csproj +++ b/src/Orchard.Web/Modules/Orchard.Indexing/Orchard.Indexing.csproj @@ -62,6 +62,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Media/DataMigrations/MediaDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Media/DataMigrations/MediaDataMigration.cs new file mode 100644 index 000000000..e46870480 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Media/DataMigrations/MediaDataMigration.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("Id", column => column.PrimaryKey()) + .Column("RootMediaFolder") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Media/Orchard.Media.csproj b/src/Orchard.Web/Modules/Orchard.Media/Orchard.Media.csproj index 88f02adab..778f23a1c 100644 --- a/src/Orchard.Web/Modules/Orchard.Media/Orchard.Media.csproj +++ b/src/Orchard.Web/Modules/Orchard.Media/Orchard.Media.csproj @@ -71,6 +71,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Roles/DataMigrations/RolesDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Roles/DataMigrations/RolesDataMigration.cs new file mode 100644 index 000000000..9a676640e --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Roles/DataMigrations/RolesDataMigration.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("Id", column => column.PrimaryKey()) + .Column("Name") + .Column("ModuleName") + .Column("Description") + ); + + //CREATE TABLE Orchard_Roles_RoleRecord (Id integer, Name TEXT, primary key (Id)); + SchemaBuilder.CreateTable("RoleRecord", table => table + .Column("Id", column => column.PrimaryKey()) + .Column("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("Id", column => column.PrimaryKey()) + .Column("Role_id") + .Column("Permission_id") + .Column("RoleRecord_Id") + ); + + //CREATE TABLE Orchard_Roles_UserRolesRecord (Id integer, UserId INTEGER, Role_id INTEGER, primary key (Id)); + SchemaBuilder.CreateTable("UserRolesRecord", table => table + .Column("Id", column => column.PrimaryKey()) + .Column("UserId") + .Column("Role_id") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Roles/Orchard.Roles.csproj b/src/Orchard.Web/Modules/Orchard.Roles/Orchard.Roles.csproj index 671501046..4a61ae7a5 100644 --- a/src/Orchard.Web/Modules/Orchard.Roles/Orchard.Roles.csproj +++ b/src/Orchard.Web/Modules/Orchard.Roles/Orchard.Roles.csproj @@ -67,6 +67,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Sandbox/DataMigrations/SandBoxDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Sandbox/DataMigrations/SandBoxDataMigration.cs new file mode 100644 index 000000000..88a9aafce --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Sandbox/DataMigrations/SandBoxDataMigration.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("Id", column => column.PrimaryKey()) + .Column("Name") + ); + + SchemaBuilder.CreateTable("SandboxSettingsRecord", table => table + .Column("Id", column => column.PrimaryKey()) + .Column("AllowAnonymousEdits") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Sandbox/Orchard.Sandbox.csproj b/src/Orchard.Web/Modules/Orchard.Sandbox/Orchard.Sandbox.csproj index 54b613b8f..9588858fa 100644 --- a/src/Orchard.Web/Modules/Orchard.Sandbox/Orchard.Sandbox.csproj +++ b/src/Orchard.Web/Modules/Orchard.Sandbox/Orchard.Sandbox.csproj @@ -67,6 +67,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Search/DataMigrations/SearchDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Search/DataMigrations/SearchDataMigration.cs new file mode 100644 index 000000000..7c53b4e43 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Search/DataMigrations/SearchDataMigration.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("Id", column => column.PrimaryKey()) + .Column("FilterCulture") + .Column("SearchedFields") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Search/Orchard.Search.csproj b/src/Orchard.Web/Modules/Orchard.Search/Orchard.Search.csproj index 725a6ece2..c99916558 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Orchard.Search.csproj +++ b/src/Orchard.Web/Modules/Orchard.Search/Orchard.Search.csproj @@ -66,6 +66,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs index 7e833695f..717003504 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.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("Current")); var dataMigrationManager = environment.Resolve(); + dataMigrationManager.Update("Orchard.Framework"); dataMigrationManager.Update("Settings"); environment.Resolve().UpdateShellDescriptor( diff --git a/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs b/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs index d0f4ee5aa..0c5deaf63 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs @@ -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; diff --git a/src/Orchard.Web/Modules/Orchard.Tags/DataMigrations/TagsDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Tags/DataMigrations/TagsDataMigration.cs new file mode 100644 index 000000000..a0d1d6c6e --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Tags/DataMigrations/TagsDataMigration.cs @@ -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("Id", column => column.PrimaryKey()) + .Column("TagName") + ); + + //CREATE TABLE Orchard_Tags_TagsContentItems (Id integer, TagId INTEGER, ContentItemId INTEGER, primary key (Id)); + SchemaBuilder.CreateTable("TagsContentItems", table => table + .Column("Id", column => column.PrimaryKey()) + .Column("TagId") + .Column("ContentItemId") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Tags/Orchard.Tags.csproj b/src/Orchard.Web/Modules/Orchard.Tags/Orchard.Tags.csproj index 2c93a394a..a698e74a8 100644 --- a/src/Orchard.Web/Modules/Orchard.Tags/Orchard.Tags.csproj +++ b/src/Orchard.Web/Modules/Orchard.Tags/Orchard.Tags.csproj @@ -67,6 +67,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Themes/DataMigrations/ThemesDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Themes/DataMigrations/ThemesDataMigration.cs new file mode 100644 index 000000000..1b79ca51b --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Themes/DataMigrations/ThemesDataMigration.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("Id", column => column.PrimaryKey()) + .Column("ThemeName") + .Column("DisplayName") + .Column("Description") + .Column("Version") + .Column("Author") + .Column("HomePage") + .Column("Tags") + ); + + //CREATE TABLE Orchard_Themes_ThemeSiteSettingsRecord (Id INTEGER not null, CurrentThemeName TEXT, primary key (Id)); + SchemaBuilder.CreateTable("ThemeSiteSettingsRecord", table => table + .Column("Id", column => column.PrimaryKey()) + .Column("CurrentThemeName") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Themes/Orchard.Themes.csproj b/src/Orchard.Web/Modules/Orchard.Themes/Orchard.Themes.csproj index 2d78f2c16..dea0eb979 100644 --- a/src/Orchard.Web/Modules/Orchard.Themes/Orchard.Themes.csproj +++ b/src/Orchard.Web/Modules/Orchard.Themes/Orchard.Themes.csproj @@ -67,6 +67,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Users/DataMigrations/UsersDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Users/DataMigrations/UsersDataMigration.cs new file mode 100644 index 000000000..d6a00bfeb --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Users/DataMigrations/UsersDataMigration.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("Id", column => column.PrimaryKey()) + .Column("UserName") + .Column("Email") + .Column("NormalizedUserName") + .Column("Password") + .Column("PasswordFormat") + .Column("PasswordSalt") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj b/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj index 747a36978..99b6fe9bb 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj +++ b/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj @@ -67,6 +67,7 @@ + diff --git a/src/Orchard/ContentManagement/DataMigrations/FrameworkDataMigration.cs b/src/Orchard/ContentManagement/DataMigrations/FrameworkDataMigration.cs new file mode 100644 index 000000000..3e0ebeabc --- /dev/null +++ b/src/Orchard/ContentManagement/DataMigrations/FrameworkDataMigration.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("Id", column => column.PrimaryKey()) + .Column("Data") + .Column("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("Id", column => column.PrimaryKey()) + .Column("Number") + .Column("Published") + .Column("Latest") + .Column("Data") + .Column("ContentItemRecord_id") + ); + + //CREATE TABLE Orchard_Framework_ContentTypeRecord (Id integer, Name TEXT, primary key (Id)); + SchemaBuilder.CreateTable("ContentTypeRecord", table => table + .Column("Id", column => column.PrimaryKey()) + .Column("Name") + ); + + //CREATE TABLE Orchard_Framework_CultureRecord (Id integer, Culture TEXT, primary key (Id)); + SchemaBuilder.CreateTable("CultureRecord", table => table + .Column("Id", column => column.PrimaryKey()) + .Column("Culture") + ); + + return 0010; + } + } +} \ No newline at end of file diff --git a/src/Orchard/ContentManagement/Records/ContentItemVersionRecord.cs b/src/Orchard/ContentManagement/Records/ContentItemVersionRecord.cs index 1eaa00875..9a7b4cf8a 100644 --- a/src/Orchard/ContentManagement/Records/ContentItemVersionRecord.cs +++ b/src/Orchard/ContentManagement/Records/ContentItemVersionRecord.cs @@ -1,5 +1,3 @@ -using System; -using Orchard.ContentManagement.FieldStorage; using Orchard.ContentManagement.FieldStorage.InfosetStorage; namespace Orchard.ContentManagement.Records { diff --git a/src/Orchard/DataMigration/Commands/DataMigrationCommands.cs b/src/Orchard/Data/Migration/Commands/DataMigrationCommands.cs similarity index 93% rename from src/Orchard/DataMigration/Commands/DataMigrationCommands.cs rename to src/Orchard/Data/Migration/Commands/DataMigrationCommands.cs index 2beb4a9d9..745b2fffd 100644 --- a/src/Orchard/DataMigration/Commands/DataMigrationCommands.cs +++ b/src/Orchard/Data/Migration/Commands/DataMigrationCommands.cs @@ -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; diff --git a/src/Orchard/DataMigration/DataMigration.cs b/src/Orchard/Data/Migration/DataMigration.cs similarity index 62% rename from src/Orchard/DataMigration/DataMigration.cs rename to src/Orchard/Data/Migration/DataMigration.cs index 8ae3769a7..28ddf9713 100644 --- a/src/Orchard/DataMigration/DataMigration.cs +++ b/src/Orchard/Data/Migration/DataMigration.cs @@ -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 { /// /// Data Migration classes can inherit from this class to get a SchemaBuilder instance configured with the current tenant database prefix /// public abstract class DataMigrationImpl : IDataMigration { - public abstract string Feature { get; } public SchemaBuilder SchemaBuilder { get; set; } + public virtual Feature Feature { get; set; } + } } diff --git a/src/Orchard/DataMigration/DataMigrationCoordinator.cs b/src/Orchard/Data/Migration/DataMigrationCoordinator.cs similarity index 95% rename from src/Orchard/DataMigration/DataMigrationCoordinator.cs rename to src/Orchard/Data/Migration/DataMigrationCoordinator.cs index 3107ea7f2..bee32f62d 100644 --- a/src/Orchard/DataMigration/DataMigrationCoordinator.cs +++ b/src/Orchard/Data/Migration/DataMigrationCoordinator.cs @@ -1,7 +1,7 @@ using Orchard.Environment; using Orchard.Environment.Extensions.Models; -namespace Orchard.DataMigration { +namespace Orchard.Data.Migration { /// /// Responsible for executing data migration tasks when a feature is enabled for the first time /// 1) Initial install of a module: diff --git a/src/Orchard/DataMigration/DataMigrationManager.cs b/src/Orchard/Data/Migration/DataMigrationManager.cs similarity index 92% rename from src/Orchard/DataMigration/DataMigrationManager.cs rename to src/Orchard/Data/Migration/DataMigrationManager.cs index c2666ac00..6c258680a 100644 --- a/src/Orchard/DataMigration/DataMigrationManager.cs +++ b/src/Orchard/Data/Migration/DataMigrationManager.cs @@ -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 { /// /// Reponsible for maintaining the knowledge of data migration in a per tenant table /// @@ -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 { /// private IEnumerable 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()) { - migration.SchemaBuilder = new SchemaBuilder(_interpreter); + migration.SchemaBuilder = new SchemaBuilder(_interpreter, migration.Feature.Descriptor.Name.Replace(".", "_") + "_"); } return migrations; diff --git a/src/Orchard/DataMigration/DefaultDataMigrationGenerator.cs b/src/Orchard/Data/Migration/DefaultDataMigrationGenerator.cs similarity index 81% rename from src/Orchard/DataMigration/DefaultDataMigrationGenerator.cs rename to src/Orchard/Data/Migration/DefaultDataMigrationGenerator.cs index f33dc4d40..5aeaea29e 100644 --- a/src/Orchard/DataMigration/DefaultDataMigrationGenerator.cs +++ b/src/Orchard/Data/Migration/DefaultDataMigrationGenerator.cs @@ -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 CreateCommands(IEnumerable records) { diff --git a/src/Orchard/Data/Migration/IDataMigration.cs b/src/Orchard/Data/Migration/IDataMigration.cs new file mode 100644 index 000000000..3cb5635ab --- /dev/null +++ b/src/Orchard/Data/Migration/IDataMigration.cs @@ -0,0 +1,7 @@ +using Orchard.Environment.Extensions.Models; + +namespace Orchard.Data.Migration { + public interface IDataMigration : IDependency { + Feature Feature { get; } + } +} diff --git a/src/Orchard/DataMigration/IDataMigrationGenerator.cs b/src/Orchard/Data/Migration/IDataMigrationGenerator.cs similarity index 80% rename from src/Orchard/DataMigration/IDataMigrationGenerator.cs rename to src/Orchard/Data/Migration/IDataMigrationGenerator.cs index a2c59b6c7..2ce898dfd 100644 --- a/src/Orchard/DataMigration/IDataMigrationGenerator.cs +++ b/src/Orchard/Data/Migration/IDataMigrationGenerator.cs @@ -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 CreateCommands(IEnumerable records); diff --git a/src/Orchard/DataMigration/IDataMigrationManager.cs b/src/Orchard/Data/Migration/IDataMigrationManager.cs similarity index 94% rename from src/Orchard/DataMigration/IDataMigrationManager.cs rename to src/Orchard/Data/Migration/IDataMigrationManager.cs index d0eff7631..509d19877 100644 --- a/src/Orchard/DataMigration/IDataMigrationManager.cs +++ b/src/Orchard/Data/Migration/IDataMigrationManager.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Orchard.DataMigration { +namespace Orchard.Data.Migration { public interface IDataMigrationManager : IDependency { /// /// Whether a feature has already been installed, i.e. one of its Data Migration class has already been processed diff --git a/src/Orchard/DataMigration/Interpreters/DefaultDataMigrationInterpreter.cs b/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs similarity index 96% rename from src/Orchard/DataMigration/Interpreters/DefaultDataMigrationInterpreter.cs rename to src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs index 3892917d5..fb2db6ee3 100644 --- a/src/Orchard/DataMigration/Interpreters/DefaultDataMigrationInterpreter.cs +++ b/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs @@ -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 _commandInterpreters; diff --git a/src/Orchard/DataMigration/Interpreters/ICommandInterpreter.cs b/src/Orchard/Data/Migration/Interpreters/ICommandInterpreter.cs similarity index 78% rename from src/Orchard/DataMigration/Interpreters/ICommandInterpreter.cs rename to src/Orchard/Data/Migration/Interpreters/ICommandInterpreter.cs index 389f3e685..e041abad9 100644 --- a/src/Orchard/DataMigration/Interpreters/ICommandInterpreter.cs +++ b/src/Orchard/Data/Migration/Interpreters/ICommandInterpreter.cs @@ -1,6 +1,6 @@ -using Orchard.DataMigration.Schema; +using Orchard.Data.Migration.Schema; -namespace Orchard.DataMigration.Interpreters { +namespace Orchard.Data.Migration.Interpreters { /// /// This interface can be implemented to provide a data migration behavior /// diff --git a/src/Orchard/DataMigration/Interpreters/IDataMigrationInterpreter.cs b/src/Orchard/Data/Migration/Interpreters/IDataMigrationInterpreter.cs similarity index 80% rename from src/Orchard/DataMigration/Interpreters/IDataMigrationInterpreter.cs rename to src/Orchard/Data/Migration/Interpreters/IDataMigrationInterpreter.cs index 0827e3a87..a2225b12f 100644 --- a/src/Orchard/DataMigration/Interpreters/IDataMigrationInterpreter.cs +++ b/src/Orchard/Data/Migration/Interpreters/IDataMigrationInterpreter.cs @@ -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); diff --git a/src/Orchard/DataMigration/Interpreters/SqLiteCommandInterpreter.cs b/src/Orchard/Data/Migration/Interpreters/SqLiteCommandInterpreter.cs similarity index 80% rename from src/Orchard/DataMigration/Interpreters/SqLiteCommandInterpreter.cs rename to src/Orchard/Data/Migration/Interpreters/SqLiteCommandInterpreter.cs index 74afe885c..0a1a5563f 100644 --- a/src/Orchard/DataMigration/Interpreters/SqLiteCommandInterpreter.cs +++ b/src/Orchard/Data/Migration/Interpreters/SqLiteCommandInterpreter.cs @@ -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, - ICommandInterpreter, + ICommandInterpreter, ICommandInterpreter, ICommandInterpreter, ICommandInterpreter, ICommandInterpreter { - + public string[] CreateStatements(DropColumnCommand command) { return new string[0]; } @@ -36,5 +36,5 @@ namespace Orchard.DataMigration.Interpreters { public string DataProvider { get { return "SQLite"; } } - } + } } diff --git a/src/Orchard/DataMigration/DataMigrationRecord.cs b/src/Orchard/Data/Migration/Records/DataMigrationRecord.cs similarity index 79% rename from src/Orchard/DataMigration/DataMigrationRecord.cs rename to src/Orchard/Data/Migration/Records/DataMigrationRecord.cs index 6f84e7d9e..2635e8cd5 100644 --- a/src/Orchard/DataMigration/DataMigrationRecord.cs +++ b/src/Orchard/Data/Migration/Records/DataMigrationRecord.cs @@ -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; } diff --git a/src/Orchard/DataMigration/Schema/AddColumnCommand.cs b/src/Orchard/Data/Migration/Schema/AddColumnCommand.cs similarity index 76% rename from src/Orchard/DataMigration/Schema/AddColumnCommand.cs rename to src/Orchard/Data/Migration/Schema/AddColumnCommand.cs index 4cfd622f8..b036d39e4 100644 --- a/src/Orchard/DataMigration/Schema/AddColumnCommand.cs +++ b/src/Orchard/Data/Migration/Schema/AddColumnCommand.cs @@ -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) { } diff --git a/src/Orchard/DataMigration/Schema/AddIndexCommand.cs b/src/Orchard/Data/Migration/Schema/AddIndexCommand.cs similarity index 86% rename from src/Orchard/DataMigration/Schema/AddIndexCommand.cs rename to src/Orchard/Data/Migration/Schema/AddIndexCommand.cs index 0f88223c2..6caf4da40 100644 --- a/src/Orchard/DataMigration/Schema/AddIndexCommand.cs +++ b/src/Orchard/Data/Migration/Schema/AddIndexCommand.cs @@ -1,4 +1,4 @@ -namespace Orchard.DataMigration.Schema { +namespace Orchard.Data.Migration.Schema { public class AddIndexCommand : TableCommand { public string IndexName { get; set; } diff --git a/src/Orchard/DataMigration/Schema/AlterColumnCommand.cs b/src/Orchard/Data/Migration/Schema/AlterColumnCommand.cs similarity index 91% rename from src/Orchard/DataMigration/Schema/AlterColumnCommand.cs rename to src/Orchard/Data/Migration/Schema/AlterColumnCommand.cs index 937019b67..711a309a6 100644 --- a/src/Orchard/DataMigration/Schema/AlterColumnCommand.cs +++ b/src/Orchard/Data/Migration/Schema/AlterColumnCommand.cs @@ -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) { diff --git a/src/Orchard/DataMigration/Schema/AlterTableCommand.cs b/src/Orchard/Data/Migration/Schema/AlterTableCommand.cs similarity index 94% rename from src/Orchard/DataMigration/Schema/AlterTableCommand.cs rename to src/Orchard/Data/Migration/Schema/AlterTableCommand.cs index 7c833c908..8c5576e3c 100644 --- a/src/Orchard/DataMigration/Schema/AlterTableCommand.cs +++ b/src/Orchard/Data/Migration/Schema/AlterTableCommand.cs @@ -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) { diff --git a/src/Orchard/DataMigration/Schema/ColumnCommand.cs b/src/Orchard/Data/Migration/Schema/ColumnCommand.cs similarity index 92% rename from src/Orchard/DataMigration/Schema/ColumnCommand.cs rename to src/Orchard/Data/Migration/Schema/ColumnCommand.cs index 4777805eb..a5fc59f13 100644 --- a/src/Orchard/DataMigration/Schema/ColumnCommand.cs +++ b/src/Orchard/Data/Migration/Schema/ColumnCommand.cs @@ -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; } diff --git a/src/Orchard/DataMigration/Schema/CreateColumnCommand.cs b/src/Orchard/Data/Migration/Schema/CreateColumnCommand.cs similarity index 94% rename from src/Orchard/DataMigration/Schema/CreateColumnCommand.cs rename to src/Orchard/Data/Migration/Schema/CreateColumnCommand.cs index 6a5dc5848..3aaf0f0f8 100644 --- a/src/Orchard/DataMigration/Schema/CreateColumnCommand.cs +++ b/src/Orchard/Data/Migration/Schema/CreateColumnCommand.cs @@ -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; diff --git a/src/Orchard/DataMigration/Schema/CreateForeignKeyCommand.cs b/src/Orchard/Data/Migration/Schema/CreateForeignKeyCommand.cs similarity index 90% rename from src/Orchard/DataMigration/Schema/CreateForeignKeyCommand.cs rename to src/Orchard/Data/Migration/Schema/CreateForeignKeyCommand.cs index 71a7d8087..09a01e2ed 100644 --- a/src/Orchard/DataMigration/Schema/CreateForeignKeyCommand.cs +++ b/src/Orchard/Data/Migration/Schema/CreateForeignKeyCommand.cs @@ -1,4 +1,4 @@ -namespace Orchard.DataMigration.Schema { +namespace Orchard.Data.Migration.Schema { public class CreateForeignKeyCommand : SchemaCommand { public string[] DestColumns { get; private set; } diff --git a/src/Orchard/DataMigration/Schema/CreateTableCommand.cs b/src/Orchard/Data/Migration/Schema/CreateTableCommand.cs similarity index 81% rename from src/Orchard/DataMigration/Schema/CreateTableCommand.cs rename to src/Orchard/Data/Migration/Schema/CreateTableCommand.cs index 8072a18ac..5c295e385 100644 --- a/src/Orchard/DataMigration/Schema/CreateTableCommand.cs +++ b/src/Orchard/Data/Migration/Schema/CreateTableCommand.cs @@ -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; diff --git a/src/Orchard/DataMigration/Schema/DropColumnCommand.cs b/src/Orchard/Data/Migration/Schema/DropColumnCommand.cs similarity index 77% rename from src/Orchard/DataMigration/Schema/DropColumnCommand.cs rename to src/Orchard/Data/Migration/Schema/DropColumnCommand.cs index 84739b096..e12c17d20 100644 --- a/src/Orchard/DataMigration/Schema/DropColumnCommand.cs +++ b/src/Orchard/Data/Migration/Schema/DropColumnCommand.cs @@ -1,4 +1,4 @@ -namespace Orchard.DataMigration.Schema { +namespace Orchard.Data.Migration.Schema { public class DropColumnCommand : ColumnCommand { public DropColumnCommand(string tableName, string columnName) diff --git a/src/Orchard/DataMigration/Schema/DropForeignKeyCommand.cs b/src/Orchard/Data/Migration/Schema/DropForeignKeyCommand.cs similarity index 84% rename from src/Orchard/DataMigration/Schema/DropForeignKeyCommand.cs rename to src/Orchard/Data/Migration/Schema/DropForeignKeyCommand.cs index ac7367cba..6ad76dab6 100644 --- a/src/Orchard/DataMigration/Schema/DropForeignKeyCommand.cs +++ b/src/Orchard/Data/Migration/Schema/DropForeignKeyCommand.cs @@ -1,4 +1,4 @@ -namespace Orchard.DataMigration.Schema { +namespace Orchard.Data.Migration.Schema { public class DropForeignKeyCommand : SchemaCommand { public string SrcTable { get; private set; } diff --git a/src/Orchard/DataMigration/Schema/DropIndexCommand.cs b/src/Orchard/Data/Migration/Schema/DropIndexCommand.cs similarity index 82% rename from src/Orchard/DataMigration/Schema/DropIndexCommand.cs rename to src/Orchard/Data/Migration/Schema/DropIndexCommand.cs index 57285a0fa..1730d7e66 100644 --- a/src/Orchard/DataMigration/Schema/DropIndexCommand.cs +++ b/src/Orchard/Data/Migration/Schema/DropIndexCommand.cs @@ -1,4 +1,4 @@ -namespace Orchard.DataMigration.Schema { +namespace Orchard.Data.Migration.Schema { public class DropIndexCommand : TableCommand { public string IndexName { get; set; } diff --git a/src/Orchard/DataMigration/Schema/DropTableCommand.cs b/src/Orchard/Data/Migration/Schema/DropTableCommand.cs similarity index 76% rename from src/Orchard/DataMigration/Schema/DropTableCommand.cs rename to src/Orchard/Data/Migration/Schema/DropTableCommand.cs index 4a8a67222..aeb6c70ef 100644 --- a/src/Orchard/DataMigration/Schema/DropTableCommand.cs +++ b/src/Orchard/Data/Migration/Schema/DropTableCommand.cs @@ -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) { diff --git a/src/Orchard/DataMigration/Schema/ISchemaBuilderCommand.cs b/src/Orchard/Data/Migration/Schema/ISchemaBuilderCommand.cs similarity index 51% rename from src/Orchard/DataMigration/Schema/ISchemaBuilderCommand.cs rename to src/Orchard/Data/Migration/Schema/ISchemaBuilderCommand.cs index da422593e..cbc613367 100644 --- a/src/Orchard/DataMigration/Schema/ISchemaBuilderCommand.cs +++ b/src/Orchard/Data/Migration/Schema/ISchemaBuilderCommand.cs @@ -1,4 +1,4 @@ -namespace Orchard.DataMigration.Schema { +namespace Orchard.Data.Migration.Schema { public interface ISchemaBuilderCommand { } } diff --git a/src/Orchard/DataMigration/Schema/IShellSettings.cs b/src/Orchard/Data/Migration/Schema/IShellSettings.cs similarity index 100% rename from src/Orchard/DataMigration/Schema/IShellSettings.cs rename to src/Orchard/Data/Migration/Schema/IShellSettings.cs diff --git a/src/Orchard/DataMigration/Schema/SchemaBuilder.cs b/src/Orchard/Data/Migration/Schema/SchemaBuilder.cs similarity index 62% rename from src/Orchard/DataMigration/Schema/SchemaBuilder.cs rename to src/Orchard/Data/Migration/Schema/SchemaBuilder.cs index c722bee4d..cfe318267 100644 --- a/src/Orchard/DataMigration/Schema/SchemaBuilder.cs +++ b/src/Orchard/Data/Migration/Schema/SchemaBuilder.cs @@ -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 table) { - var createTable = new CreateTableCommand(name); + var createTable = new CreateTableCommand(String.Concat(_featurePrefix, name)); table(createTable); Run(createTable); return this; } - public SchemaBuilder CreateTable(Action table) { - return CreateTable(typeof (TRecord).FullName.Replace(".", "_"), table); - } - public SchemaBuilder AlterTable(string name, Action 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; } diff --git a/src/Orchard/DataMigration/Schema/SchemaCommand.cs b/src/Orchard/Data/Migration/Schema/SchemaCommand.cs similarity index 91% rename from src/Orchard/DataMigration/Schema/SchemaCommand.cs rename to src/Orchard/Data/Migration/Schema/SchemaCommand.cs index 64176e935..d52155768 100644 --- a/src/Orchard/DataMigration/Schema/SchemaCommand.cs +++ b/src/Orchard/Data/Migration/Schema/SchemaCommand.cs @@ -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(); diff --git a/src/Orchard/DataMigration/Schema/SqlStatementCommand.cs b/src/Orchard/Data/Migration/Schema/SqlStatementCommand.cs similarity index 90% rename from src/Orchard/DataMigration/Schema/SqlStatementCommand.cs rename to src/Orchard/Data/Migration/Schema/SqlStatementCommand.cs index b730b7863..059fb56d3 100644 --- a/src/Orchard/DataMigration/Schema/SqlStatementCommand.cs +++ b/src/Orchard/Data/Migration/Schema/SqlStatementCommand.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Orchard.DataMigration.Schema { +namespace Orchard.Data.Migration.Schema { public class SqlStatementCommand : SchemaCommand { protected readonly List _providers; public SqlStatementCommand(string sql) diff --git a/src/Orchard/DataMigration/Schema/TableCommand.cs b/src/Orchard/Data/Migration/Schema/TableCommand.cs similarity index 79% rename from src/Orchard/DataMigration/Schema/TableCommand.cs rename to src/Orchard/Data/Migration/Schema/TableCommand.cs index 3d4092fec..d62e8599f 100644 --- a/src/Orchard/DataMigration/Schema/TableCommand.cs +++ b/src/Orchard/Data/Migration/Schema/TableCommand.cs @@ -1,4 +1,4 @@ -namespace Orchard.DataMigration.Schema { +namespace Orchard.Data.Migration.Schema { public class TableCommand : ISchemaBuilderCommand{ public string TableName { get; private set; } diff --git a/src/Orchard/DataMigration/IDataMigration.cs b/src/Orchard/DataMigration/IDataMigration.cs deleted file mode 100644 index 58267f100..000000000 --- a/src/Orchard/DataMigration/IDataMigration.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Orchard.DataMigration { - public interface IDataMigration : IDependency { - string Feature { get; } - } -} diff --git a/src/Orchard/Orchard.Framework.csproj b/src/Orchard/Orchard.Framework.csproj index 2d93e7a09..1d99ebf36 100644 --- a/src/Orchard/Orchard.Framework.csproj +++ b/src/Orchard/Orchard.Framework.csproj @@ -356,37 +356,38 @@ Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +