Refactored data migration to correct SQL Server bugs

- Added explicit Identity column specification
- Defined string lengths explicitly on needed columns

--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2010-07-08 15:18:13 -07:00
parent 199c462d4d
commit 7abd8ac71c
15 changed files with 65 additions and 39 deletions

View File

@@ -8,7 +8,7 @@ namespace Orchard.Core.Common.DataMigrations {
//CREATE TABLE Common_BodyRecord (Id INTEGER not null, Text TEXT, Format TEXT, ContentItemRecord_id INTEGER, primary key (Id));
SchemaBuilder.CreateTable("BodyRecord", table => table
.ContentPartVersionRecord()
.Column<string>("Text")
.Column<string>("Text", column => column.WithLength(10000))
.Column<string>("Format")
);
@@ -33,9 +33,9 @@ namespace Orchard.Core.Common.DataMigrations {
//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
.ContentPartVersionRecord()
.Column<string>("Title")
.Column<string>("Title", column => column.WithLength(1024))
.Column<string>("Slug")
.Column<string>("Path")
.Column<string>("Path", column => column.WithLength(2048))
);
return 0010;

View File

@@ -7,7 +7,7 @@ namespace Orchard.Core.Scheduling.DataMigrations {
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<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("TaskType")
.Column<DateTime>("ScheduledUtc")
.Column<int>("ContentItemVersionRecord_id")

View File

@@ -6,13 +6,13 @@ namespace Orchard.Core.Settings.DataMigrations {
public int Create() {
//CREATE TABLE Settings_ContentFieldDefinitionRecord (Id integer, Name TEXT, primary key (Id));
SchemaBuilder.CreateTable("ContentFieldDefinitionRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Name")
);
//CREATE TABLE Settings_ContentPartDefinitionRecord (Id integer, Name TEXT, Hidden INTEGER, Settings TEXT, primary key (Id));
SchemaBuilder.CreateTable("ContentPartDefinitionRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Name")
.Column<bool>("Hidden")
.Column<string>("Settings")
@@ -20,7 +20,7 @@ namespace Orchard.Core.Settings.DataMigrations {
//CREATE TABLE Settings_ContentPartFieldDefinitionRecord (Id integer, Name TEXT, Settings TEXT, ContentFieldDefinitionRecord_id INTEGER, INTEGER, primary key (Id));
SchemaBuilder.CreateTable("ContentPartFieldDefinitionRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Name")
.Column<string>("Settings")
.Column<int>("ContentFieldDefinitionRecord_id")
@@ -29,7 +29,7 @@ namespace Orchard.Core.Settings.DataMigrations {
//CREATE TABLE Settings_ContentTypeDefinitionRecord (Id integer, Name TEXT, DisplayName TEXT, Hidden INTEGER, Settings TEXT, primary key (Id));
SchemaBuilder.CreateTable("ContentTypeDefinitionRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Name")
.Column<string>("DisplayName")
.Column<bool>("Hidden")
@@ -38,7 +38,7 @@ namespace Orchard.Core.Settings.DataMigrations {
//CREATE TABLE Settings_ContentTypePartDefinitionRecord (Id integer, Settings TEXT, ContentPartDefinitionRecord_id INTEGER, ContentTypeDefinitionRecord_Id INTEGER, primary key (Id));
SchemaBuilder.CreateTable("ContentTypePartDefinitionRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Settings")
.Column<int>("ContentPartDefinitionRecord_id")
.Column<int>("ContentTypeDefinitionRecord_Id")
@@ -46,19 +46,19 @@ namespace Orchard.Core.Settings.DataMigrations {
//CREATE TABLE Settings_ShellDescriptorRecord (Id integer, SerialNumber INTEGER, primary key (Id));
SchemaBuilder.CreateTable("ShellDescriptorRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<int>("SerialNumber")
);
//CREATE TABLE Settings_ShellFeatureRecord (Id integer, Name TEXT, ShellDescriptorRecord_id INTEGER, primary key (Id));
SchemaBuilder.CreateTable("ShellFeatureRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.Column<int>("Id", column => column.PrimaryKey().Identity())
.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("ShellFeatureStateRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Name")
.Column<string>("InstallState")
.Column<string>("EnableState")
@@ -67,7 +67,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("ShellParameterRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Component")
.Column<string>("Name")
.Column<string>("Value")
@@ -76,7 +76,7 @@ namespace Orchard.Core.Settings.DataMigrations {
//CREATE TABLE Settings_ShellStateRecord (Id integer, primary key (Id));
SchemaBuilder.CreateTable("ShellStateRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Name")
);

View File

@@ -6,7 +6,7 @@ namespace Orchard.Blogs.DataMigrations {
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>("Id", column => column.PrimaryKey().Identity())
.Column<int>("Year")
.Column<int>("Month")
.Column<int>("PostCount")
@@ -15,7 +15,7 @@ namespace Orchard.Blogs.DataMigrations {
//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())
.ContentPartRecord()
.Column<string>("Description")
.Column<int>("PostCount")
);

View File

@@ -7,7 +7,7 @@ namespace Orchard.Comments.DataMigrations {
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>("Id", column => column.PrimaryKey().Identity())
.Column<int>("ContentItemId")
);
@@ -20,7 +20,7 @@ namespace Orchard.Comments.DataMigrations {
.Column<string>("Email")
.Column<string>("Status")
.Column<DateTime>("CommentDateUtc")
.Column<string>("CommentText")
.Column<string>("CommentText", column => column.WithLength(10000))
.Column<int>("CommentedOn")
.Column<int>("CommentedOnContainer")
);

View File

@@ -6,7 +6,7 @@ namespace Orchard.Roles.DataMigrations {
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<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Name")
.Column<string>("ModuleName")
.Column<string>("Description")
@@ -14,13 +14,13 @@ namespace Orchard.Roles.DataMigrations {
//CREATE TABLE Orchard_Roles_RoleRecord (Id integer, Name TEXT, primary key (Id));
SchemaBuilder.CreateTable("RoleRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.Column<int>("Id", column => column.PrimaryKey().Identity())
.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>("Id", column => column.PrimaryKey().Identity())
.Column<int>("Role_id")
.Column<int>("Permission_id")
.Column<int>("RoleRecord_Id")
@@ -28,7 +28,7 @@ namespace Orchard.Roles.DataMigrations {
//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>("Id", column => column.PrimaryKey().Identity())
.Column<int>("UserId")
.Column<int>("Role_id")
);

View File

@@ -9,6 +9,7 @@ using Orchard.Core.Common.Settings;
using Orchard.Core.Navigation.Models;
using Orchard.Core.Settings.Models;
using Orchard.Data;
using Orchard.Data.Migration.Generator;
using Orchard.Data.Migration.Interpreters;
using Orchard.Data.Providers;
using Orchard.Data.Migration.Schema;
@@ -89,6 +90,7 @@ namespace Orchard.Setup.Services {
context.EnabledFeatures = hardcoded;
}
var shellSettings = new ShellSettings(_shellSettings);
if (string.IsNullOrEmpty(shellSettings.DataProvider)) {
@@ -110,7 +112,7 @@ namespace Orchard.Setup.Services {
var schemaBuilder = new SchemaBuilder(environment.Resolve<IDataMigrationInterpreter>() );
schemaBuilder.CreateTable("Orchard_Framework_DataMigrationRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("DataMigrationClass")
.Column<int>("Version"));

View File

@@ -6,13 +6,13 @@ namespace Orchard.Tags.DataMigrations {
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<int>("Id", column => column.PrimaryKey().Identity())
.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>("Id", column => column.PrimaryKey().Identity())
.Column<int>("TagId")
.Column<int>("ContentItemId")
);