/
Migrations.cs
105 lines (88 loc) · 5 KB
/
Migrations.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;
namespace NGM.Forum {
public class Migrations : DataMigrationImpl {
public int Create() {
SchemaBuilder.CreateTable("ForumPartRecord",
table => table
.ContentPartRecord()
.Column<string>("Description", column => column.Unlimited())
.Column<int>("ThreadCount")
.Column<int>("PostCount")
.Column<bool>("ThreadedPosts")
.Column<int>("Weight")
);
SchemaBuilder.CreateTable("ThreadPartRecord",
table => table
.ContentPartRecord()
.Column<int>("PostCount")
.Column<bool>("IsSticky")
.Column<int>("ClosedById")
.Column<DateTime>("ClosedOnUtc", column => column.WithDefault(null))
.Column<string>("ClosedDescription", column => column.Unlimited())
);
SchemaBuilder.CreateTable("PostPartRecord",
table => table
.ContentPartVersionRecord()
.Column<int>("RepliedOn", column => column.WithDefault(null))
.Column<string>("Text", column => column.Unlimited())
.Column<string>("Format")
);
ContentDefinitionManager.AlterPartDefinition("ForumPart", builder => builder
.Attachable()
.WithDescription("Create your own Forum Type with a hierarchy of different threads/posts"));
ContentDefinitionManager.AlterPartDefinition("ThreadPart", builder => builder
.Attachable()
.WithDescription("Create your own Thread Type, useful when wanting different types of threads for different forums"));
ContentDefinitionManager.AlterPartDefinition("PostPart", builder => builder
.Attachable()
.WithDescription("Create your own Post Type, useful when wanting different types of posts for different forums"));
ContentDefinitionManager.AlterTypeDefinition("Forum", cfg => cfg
.WithPart("ForumPart")
.WithPart("CommonPart")
.WithPart("TitlePart")
.WithPart("AutoroutePart", builder => builder
.WithSetting("AutorouteSettings.AllowCustomPattern", "true")
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
.WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-forum'}]")
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
.WithPart("MenuPart")
);
ContentDefinitionManager.AlterTypeDefinition("Thread", cfg => cfg
.WithPart("ThreadPart")
.WithPart("CommonPart", builder => builder
.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false"))
.WithPart("TitlePart")
.WithPart("AutoroutePart", builder => builder
.WithSetting("AutorouteSettings.AllowCustomPattern", "false")
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
.WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Forum and Title', Pattern: '{Content.Container.Path}/{Content.Slug}', Description: 'my-forum/my-thread'}]")
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
);
ContentDefinitionManager.AlterTypeDefinition("Post", cfg => cfg
.WithPart("PostPart")
.WithPart("CommonPart", builder => builder
.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false"))
);
return 3;
}
public int UpdateFrom1() {
SchemaBuilder.AlterTable("ForumPartRecord", command => command.AddColumn<int>("Weight"));
return 2;
}
public int UpdateFrom2() {
ContentDefinitionManager.AlterPartDefinition("ForumPart", builder => builder
.Attachable()
.WithDescription("Create your own Forum Type with a hierarchy of different threads/posts"));
ContentDefinitionManager.AlterPartDefinition("ThreadPart", builder => builder
.Attachable()
.WithDescription("Create your own Thread Type, useful when wanting different types of threads for different forums"));
ContentDefinitionManager.AlterPartDefinition("PostPart", builder => builder
.Attachable()
.WithDescription("Create your own Post Type, useful when wanting different types of posts for different forums"));
return 3;
}
}
}