2010-06-29 16:17:08 -07:00
|
|
|
|
using System;
|
2010-07-21 21:49:25 -07:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Orchard.Comments.Models;
|
|
|
|
|
using Orchard.ContentManagement.Drivers;
|
2010-07-21 17:19:28 -07:00
|
|
|
|
using Orchard.ContentManagement.MetaData;
|
2010-07-21 21:49:25 -07:00
|
|
|
|
using Orchard.ContentManagement.MetaData.Builders;
|
2010-06-29 16:17:08 -07:00
|
|
|
|
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
|
2010-07-08 15:18:13 -07:00
|
|
|
|
.Column<int>("Id", column => column.PrimaryKey().Identity())
|
2010-06-29 16:17:08 -07:00
|
|
|
|
.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
|
2010-07-07 16:29:58 -07:00
|
|
|
|
.ContentPartRecord()
|
2010-06-29 16:17:08 -07:00
|
|
|
|
.Column<string>("Author")
|
|
|
|
|
.Column<string>("SiteName")
|
|
|
|
|
.Column<string>("UserName")
|
|
|
|
|
.Column<string>("Email")
|
|
|
|
|
.Column<string>("Status")
|
|
|
|
|
.Column<DateTime>("CommentDateUtc")
|
2010-07-16 13:51:07 -07:00
|
|
|
|
.Column<string>("CommentText", column => column.Unlimited())
|
2010-06-29 16:17:08 -07:00
|
|
|
|
.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
|
2010-07-07 16:29:58 -07:00
|
|
|
|
.ContentPartRecord()
|
2010-06-29 16:17:08 -07:00
|
|
|
|
.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
|
2010-07-07 16:29:58 -07:00
|
|
|
|
.ContentPartRecord()
|
2010-06-29 16:17:08 -07:00
|
|
|
|
.Column<bool>("CommentsShown")
|
|
|
|
|
.Column<bool>("CommentsActive")
|
|
|
|
|
);
|
|
|
|
|
|
2010-07-19 15:39:58 -07:00
|
|
|
|
return 1;
|
2010-06-29 16:17:08 -07:00
|
|
|
|
}
|
2010-07-21 17:19:28 -07:00
|
|
|
|
|
|
|
|
|
public int UpdateFrom1() {
|
|
|
|
|
ContentDefinitionManager.AlterTypeDefinition("Comment",
|
|
|
|
|
cfg => cfg
|
|
|
|
|
.WithPart("Comment")
|
|
|
|
|
.WithPart("CommonAspect")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
ContentDefinitionManager.AlterTypeDefinition("Blog",
|
|
|
|
|
cfg => cfg
|
|
|
|
|
.WithPart("HasCommentsContainer")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
2010-07-21 21:49:25 -07:00
|
|
|
|
|
|
|
|
|
public int UpdateFrom2() {
|
|
|
|
|
ContentDefinitionManager.AlterPartDefinition(typeof(HasComments).Name, cfg => cfg
|
|
|
|
|
.WithLocation(new Dictionary<string, ContentLocation> {
|
|
|
|
|
{"Default", new ContentLocation { Zone = "primary", Position = "before.5" }},
|
|
|
|
|
{"Detail", new ContentLocation { Zone = "primary", Position = "after.5" }},
|
|
|
|
|
{"SummaryAdmin", new ContentLocation { Zone = "meta", Position = null }},
|
|
|
|
|
{"Summary", new ContentLocation { Zone = "meta", Position = "5" }},
|
|
|
|
|
{"Editor", new ContentLocation { Zone = "primary", Position = "10" }},
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
ContentDefinitionManager.AlterPartDefinition(typeof(HasCommentsContainer).Name, cfg => cfg
|
|
|
|
|
.WithLocation(new Dictionary<string, ContentLocation> {
|
|
|
|
|
{"SummaryAdmin", new ContentLocation { Zone = "meta", Position = null }},
|
|
|
|
|
{"Summary", new ContentLocation { Zone = "meta", Position = null }},
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
return 3;
|
|
|
|
|
}
|
2010-06-29 16:17:08 -07:00
|
|
|
|
}
|
|
|
|
|
}
|