-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathMigrations.cs
135 lines (111 loc) · 6.63 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using System.Data;
using Orchard.ContentManagement.MetaData;
using Orchard.Data.Migration;
namespace NGM.OpenAuthentication {
public class Migrations : DataMigrationImpl {
public int Create() {
SchemaBuilder.CreateTable("UserProviderRecord",
table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<int>("UserId")
.Column<string>("ProviderName")
.Column<string>("ProviderUserId")
);
SchemaBuilder.CreateTable("ProviderConfigurationRecord",
table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<int>("IsEnabled")
.Column<string>("DisplayName")
.Column<string>("ProviderName")
.Column<string>("ProviderIdKey")
.Column<string>("ProviderSecret")
.Column<string>("ProviderIdentifier")
);
return 8;
}
public int UpdateFrom1() {
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.AddColumn<bool>("MicrosoftConnectEnabled"));
return 2;
}
public int UpdateFrom2() {
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("MicrosoftConnectEnabled"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("OpenIdEnabled"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("CardSpaceEnabled"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("OAuthEnabled"));
return 3;
}
public int UpdateFrom3() {
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("Birthdate"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("Country"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("Email"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("FullName"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("Gender"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("Language"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("Nickname"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("PostalCode"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("TimeZone"));
SchemaBuilder.CreateTable("OpenAuthenticationPermissionSettingsPartRecord", table => table
.ContentPartRecord()
.Column<string>("NamedPermission")
.Column<bool>("IsEnabled")
.Column<int>("HashedProvider")
);
return 4;
}
public int UpdateFrom4() {
ContentDefinitionManager.AlterTypeDefinition("OpenAuthentication",
cfg => cfg
.WithPart("OpenAuthenticationPart"));
return 5;
}
public int UpdateFrom5() {
SchemaBuilder.DropTable("OpenAuthenticationPermissionSettingsPartRecord");
SchemaBuilder.CreateTable("ScopeProviderPermissionRecord",
table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Resource")
.Column<string>("Scope")
.Column<string>("Description")
.Column<bool>("IsEnabled")
.Column<int>("HashedProvider")
);
return 6;
}
public int UpdateFrom6() {
SchemaBuilder.AlterTable("ScopeProviderPermissionRecord", table => table.AlterColumn("HashedProvider", x => x.WithType(DbType.String)));
SchemaBuilder.AlterTable("OpenAuthenticationPartRecord", table => table.AlterColumn("HashedProvider", x => x.WithType(DbType.String)));
return 7;
}
public int UpdateFrom7() {
ContentDefinitionManager.AlterTypeDefinition("User", cfg => cfg.RemovePart("OpenAuthenticationPart"));
SchemaBuilder.DropTable("OpenAuthenticationPartRecord");
SchemaBuilder.DropTable("ScopeProviderPermissionRecord");
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("AutoRegisterEnabled"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("FacebookClientIdentifier"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("FacebookClientSecret"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("TwitterClientIdentifier"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("TwitterClientSecret"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("LiveIdClientIdentifier"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.DropColumn("LiveIdClientSecret"));
SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", t => t.AddColumn<bool>("AutoRegistrationEnabled"));
SchemaBuilder.CreateTable("UserProviderRecord",
table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<int>("UserId")
.Column<string>("ProviderName")
.Column<string>("ProviderUserId")
);
SchemaBuilder.CreateTable("ProviderConfigurationRecord",
table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<int>("IsEnabled")
.Column<string>("DisplayName")
.Column<string>("ProviderName")
.Column<string>("ProviderIdKey")
.Column<string>("ProviderSecret")
.Column<string>("ProviderIdentifier")
);
return 8;
}
}
}