-
Notifications
You must be signed in to change notification settings - Fork 0
/
Migrations.cs
55 lines (49 loc) · 2.2 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
using Codesanook.Users.Models;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;
namespace Codesanook.Users {
public class Migrations : DataMigrationImpl {
public int Create() {
// Naming convention for Lambda parameter
// prefer abbreviation when it is clear about the context
// prefer long name when it is hard to reference context
// For Orchard migration, use:
// table parameter for CreateTableCommand
// column parameter for CreateColumnCommand
// type parameter for ContentTypeDefinitionBuilder
// part for ContentPartDefinitionBuilder
// Create UserProfilePartRecord table
SchemaBuilder.CreateTable(
nameof(BasicUserProfilePartRecord),
table => table
.ContentPartRecord()
.Column<string>(
nameof(BasicUserProfilePartRecord.FirstName),
column => column.WithLength(64)
)
.Column<string>(
nameof(BasicUserProfilePartRecord.LastName),
column => column.WithLength(64)
)
.Column<string>(
nameof(BasicUserProfilePartRecord.MobilePhoneNumber),
column => column.WithLength(10)
)
.Column<string>(
nameof(BasicUserProfilePartRecord.OrganizationName),
column => column.WithLength(64)
)
);
// Create a content part
ContentDefinitionManager.AlterPartDefinition(
nameof(BasicUserProfilePart),
part => part
.Attachable()
.WithDescription("Provide a basic user profile part, e.g. FirstName, LastName, MobilePhoneNumber, OrganizationName")
);
// Let's Add UserProfilePart to existing User type manually from the admin dashboard
return 1;
}
}
}