Implement ContentPartRecord and ContentPartVersionRecord for migration classes, to get rid of the explicit IDs

--HG--
branch : dev
This commit is contained in:
Sebastien Ros 2010-07-07 16:29:58 -07:00
parent 322125a33f
commit d1a4edd349
12 changed files with 30 additions and 26 deletions

View File

@ -7,15 +7,14 @@ namespace Orchard.Core.Common.DataMigrations {
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())
.ContentPartVersionRecord()
.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())
.ContentPartRecord()
.Column<int>("OwnerId")
.Column<DateTime>("CreatedUtc")
.Column<DateTime>("PublishedUtc")
@ -25,20 +24,18 @@ namespace Orchard.Core.Common.DataMigrations {
//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())
.ContentPartVersionRecord()
.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())
.ContentPartVersionRecord()
.Column<string>("Title")
.Column<string>("Slug")
.Column<string>("Path")
.Column<int>("ContentItemRecord_id")
);
return 0010;

View File

@ -6,7 +6,7 @@ namespace Orchard.Core.Localization.DataMigrations {
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())
.ContentPartRecord()
.Column<int>("CultureId")
.Column<int>("MasterContentItemId")
);

View File

@ -6,13 +6,13 @@ namespace Orchard.Core.Navigation.DataMigrations {
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())
.ContentPartRecord()
.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())
.ContentPartRecord()
.Column<string>("MenuText")
.Column<string>("MenuPosition")
.Column<bool>("OnMainMenu")

View File

@ -82,7 +82,7 @@ namespace Orchard.Core.Settings.DataMigrations {
//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())
.ContentPartRecord()
.Column<string>("SiteSalt")
.Column<string>("SiteName")
.Column<string>("SuperUser")

View File

@ -11,7 +11,7 @@ namespace Futures.Widgets.DataMigrations {
//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())
.ContentPartRecord()
.Column<string>("Zone")
.Column<string>("Position")
.Column<int>("Scope_id")

View File

@ -13,7 +13,7 @@ namespace Orchard.Comments.DataMigrations {
//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())
.ContentPartRecord()
.Column<string>("Author")
.Column<string>("SiteName")
.Column<string>("UserName")
@ -27,7 +27,7 @@ namespace Orchard.Comments.DataMigrations {
//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())
.ContentPartRecord()
.Column<bool>("ModerateComments")
.Column<bool>("EnableSpamProtection")
.Column<string>("AkismetKey")
@ -36,7 +36,7 @@ namespace Orchard.Comments.DataMigrations {
//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())
.ContentPartRecord()
.Column<bool>("CommentsShown")
.Column<bool>("CommentsActive")
);

View File

@ -6,7 +6,7 @@ namespace Orchard.Media.DataMigrations {
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())
.ContentPartRecord()
.Column<string>("RootMediaFolder")
);

View File

@ -5,12 +5,12 @@ namespace Orchard.Sandbox.DataMigrations {
public int Create() {
SchemaBuilder.CreateTable("SandboxPageRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.ContentPartRecord()
.Column<string>("Name")
);
SchemaBuilder.CreateTable("SandboxSettingsRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.ContentPartRecord()
.Column<bool>("AllowAnonymousEdits")
);

View File

@ -6,7 +6,7 @@ namespace Orchard.Search.DataMigrations {
public int Create() {
SchemaBuilder.CreateTable("SearchSettingsRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
.ContentPartRecord()
.Column<bool>("FilterCulture")
.Column<string>("SearchedFields")
);

View File

@ -6,7 +6,7 @@ namespace Orchard.Themes.DataMigrations {
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())
.ContentPartRecord()
.Column<string>("ThemeName")
.Column<string>("DisplayName")
.Column<string>("Description")
@ -18,7 +18,7 @@ namespace Orchard.Themes.DataMigrations {
//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())
.ContentPartRecord()
.Column<string>("CurrentThemeName")
);

View File

@ -6,7 +6,7 @@ namespace Orchard.Users.DataMigrations {
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())
.ContentPartRecord()
.Column<string>("UserName")
.Column<string>("Email")
.Column<string>("NormalizedUserName")

View File

@ -23,16 +23,23 @@ namespace Orchard.Data.Migration.Schema {
return Column(columnName, dbType, column);
}
/// <summary>
/// Defines a primary column as for content parts
/// </summary>
public CreateTableCommand ContentPartRecord() {
/// TODO: Call Column() with necessary information for content part records
Column<int>("Id", column => column.PrimaryKey());
return this;
}
public CreateTableCommand VersionedContentPartRecord() {
/// TODO: Call Column() with necessary information for content part records
/// <summary>
/// Defines a primary column as for versionnable content parts
/// </summary>
public CreateTableCommand ContentPartVersionRecord() {
Column<int>("Id", column => column.PrimaryKey());
Column<int>("ContentItemRecord_id");
return this;
}
}
}