14 protected override void Up(MigrationBuilder migrationBuilder)
16 ArgumentNullException.ThrowIfNull(migrationBuilder);
18 migrationBuilder.CreateTable(
22 Id = table.Column<
long>(nullable:
false)
23 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
24 Name = table.Column<
string>(maxLength: 10000, nullable:
false),
25 Path = table.Column<
string>(nullable:
false),
26 Online = table.Column<
bool>(nullable:
false),
27 ConfigurationType = table.Column<
int>(nullable:
false),
28 AutoUpdateInterval = table.Column<
long>(nullable:
false),
29 ChatBotLimit = table.Column<
int>(nullable:
false),
33 table.PrimaryKey(
"PK_Instances", x => x.Id);
36 migrationBuilder.CreateTable(
40 Id = table.Column<
long>(nullable:
false)
41 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
42 Enabled = table.Column<
bool>(nullable:
false),
43 CreatedAt = table.Column<DateTimeOffset>(nullable:
false),
44 SystemIdentifier = table.Column<
string>(nullable:
true),
45 Name = table.Column<
string>(maxLength: 10000, nullable:
false),
46 AdministrationRights = table.Column<decimal>(nullable:
false),
47 InstanceManagerRights = table.Column<decimal>(nullable:
false),
48 PasswordHash = table.Column<
string>(nullable:
true),
49 CreatedById = table.Column<
long>(nullable:
true),
50 CanonicalName = table.Column<
string>(nullable:
false),
51 LastPasswordUpdate = table.Column<DateTimeOffset>(nullable:
true),
55 table.PrimaryKey(
"PK_Users", x => x.Id);
57 name:
"FK_Users_Users_CreatedById",
58 column: x => x.CreatedById,
59 principalTable:
"Users",
60 principalColumn:
"Id",
61 onDelete: ReferentialAction.Restrict);
64 migrationBuilder.CreateTable(
68 Id = table.Column<
long>(nullable:
false)
69 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
70 Name = table.Column<
string>(maxLength: 100, nullable:
false),
71 Enabled = table.Column<
bool>(nullable:
true),
72 ReconnectionInterval = table.Column<
long>(nullable:
false),
73 ChannelLimit = table.Column<
int>(nullable:
false),
74 Provider = table.Column<
int>(nullable:
false),
75 ConnectionString = table.Column<
string>(maxLength: 10000, nullable:
false),
76 InstanceId = table.Column<
long>(nullable:
false),
80 table.PrimaryKey(
"PK_ChatBots", x => x.Id);
82 name:
"FK_ChatBots_Instances_InstanceId",
83 column: x => x.InstanceId,
84 principalTable:
"Instances",
85 principalColumn:
"Id",
86 onDelete: ReferentialAction.Cascade);
89 migrationBuilder.CreateTable(
90 name:
"DreamDaemonSettings",
93 Id = table.Column<
long>(nullable:
false)
94 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
95 AllowWebClient = table.Column<
bool>(nullable:
false),
96 SecurityLevel = table.Column<
int>(nullable:
false),
97 PrimaryPort = table.Column<
int>(nullable:
false),
98 SecondaryPort = table.Column<
int>(nullable:
false),
99 StartupTimeout = table.Column<
long>(nullable:
false),
100 HeartbeatSeconds = table.Column<
long>(nullable:
false),
101 AutoStart = table.Column<
bool>(nullable:
false),
102 InstanceId = table.Column<
long>(nullable:
false),
104 constraints: table =>
106 table.PrimaryKey(
"PK_DreamDaemonSettings", x => x.Id);
108 name:
"FK_DreamDaemonSettings_Instances_InstanceId",
109 column: x => x.InstanceId,
110 principalTable:
"Instances",
111 principalColumn:
"Id",
112 onDelete: ReferentialAction.Cascade);
115 migrationBuilder.CreateTable(
116 name:
"DreamMakerSettings",
117 columns: table =>
new
119 Id = table.Column<
long>(nullable:
false)
120 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
121 ProjectName = table.Column<
string>(maxLength: 10000, nullable:
true),
122 ApiValidationPort = table.Column<
int>(nullable:
false),
123 ApiValidationSecurityLevel = table.Column<
int>(nullable:
false),
124 InstanceId = table.Column<
long>(nullable:
false),
126 constraints: table =>
128 table.PrimaryKey(
"PK_DreamMakerSettings", x => x.Id);
130 name:
"FK_DreamMakerSettings_Instances_InstanceId",
131 column: x => x.InstanceId,
132 principalTable:
"Instances",
133 principalColumn:
"Id",
134 onDelete: ReferentialAction.Cascade);
137 migrationBuilder.CreateTable(
138 name:
"RepositorySettings",
139 columns: table =>
new
141 Id = table.Column<
long>(nullable:
false)
142 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
143 CommitterName = table.Column<
string>(maxLength: 10000, nullable:
false),
144 CommitterEmail = table.Column<
string>(maxLength: 10000, nullable:
false),
145 AccessUser = table.Column<
string>(maxLength: 10000, nullable:
true),
146 AccessToken = table.Column<
string>(maxLength: 10000, nullable:
true),
147 PushTestMergeCommits = table.Column<
bool>(nullable:
false),
148 ShowTestMergeCommitters = table.Column<
bool>(nullable:
false),
149 AutoUpdatesKeepTestMerges = table.Column<
bool>(nullable:
false),
150 AutoUpdatesSynchronize = table.Column<
bool>(nullable:
false),
151 PostTestMergeComment = table.Column<
bool>(nullable:
false),
152 InstanceId = table.Column<
long>(nullable:
false),
154 constraints: table =>
156 table.PrimaryKey(
"PK_RepositorySettings", x => x.Id);
158 name:
"FK_RepositorySettings_Instances_InstanceId",
159 column: x => x.InstanceId,
160 principalTable:
"Instances",
161 principalColumn:
"Id",
162 onDelete: ReferentialAction.Cascade);
165 migrationBuilder.CreateTable(
166 name:
"RevisionInformations",
167 columns: table =>
new
169 Id = table.Column<
long>(nullable:
false)
170 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
171 CommitSha = table.Column<
string>(maxLength: 40, nullable:
false),
172 OriginCommitSha = table.Column<
string>(maxLength: 40, nullable:
false),
173 InstanceId = table.Column<
long>(nullable:
false),
175 constraints: table =>
177 table.PrimaryKey(
"PK_RevisionInformations", x => x.Id);
179 name:
"FK_RevisionInformations_Instances_InstanceId",
180 column: x => x.InstanceId,
181 principalTable:
"Instances",
182 principalColumn:
"Id",
183 onDelete: ReferentialAction.Cascade);
186 migrationBuilder.CreateTable(
187 name:
"InstanceUsers",
188 columns: table =>
new
190 Id = table.Column<
long>(nullable:
false)
191 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
192 UserId = table.Column<
long>(nullable:
false),
193 InstanceUserRights = table.Column<decimal>(nullable:
false),
194 ByondRights = table.Column<decimal>(nullable:
false),
195 DreamDaemonRights = table.Column<decimal>(nullable:
false),
196 DreamMakerRights = table.Column<decimal>(nullable:
false),
197 RepositoryRights = table.Column<decimal>(nullable:
false),
198 ChatBotRights = table.Column<decimal>(nullable:
false),
199 ConfigurationRights = table.Column<decimal>(nullable:
false),
200 InstanceId = table.Column<
long>(nullable:
false),
202 constraints: table =>
204 table.PrimaryKey(
"PK_InstanceUsers", x => x.Id);
206 name:
"FK_InstanceUsers_Instances_InstanceId",
207 column: x => x.InstanceId,
208 principalTable:
"Instances",
209 principalColumn:
"Id",
210 onDelete: ReferentialAction.Cascade);
212 name:
"FK_InstanceUsers_Users_UserId",
213 column: x => x.UserId,
214 principalTable:
"Users",
215 principalColumn:
"Id",
216 onDelete: ReferentialAction.Cascade);
219 migrationBuilder.CreateTable(
221 columns: table =>
new
223 Id = table.Column<
long>(nullable:
false)
224 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
225 Description = table.Column<
string>(nullable:
false),
226 ErrorCode = table.Column<
long>(nullable:
true),
227 ExceptionDetails = table.Column<
string>(nullable:
true),
228 StartedAt = table.Column<DateTimeOffset>(nullable:
false),
229 StoppedAt = table.Column<DateTimeOffset>(nullable:
true),
230 Cancelled = table.Column<
bool>(nullable:
false),
231 CancelRightsType = table.Column<decimal>(nullable:
true),
232 CancelRight = table.Column<decimal>(nullable:
true),
233 StartedById = table.Column<
long>(nullable:
false),
234 CancelledById = table.Column<
long>(nullable:
true),
235 InstanceId = table.Column<
long>(nullable:
false),
237 constraints: table =>
239 table.PrimaryKey(
"PK_Jobs", x => x.Id);
241 name:
"FK_Jobs_Users_CancelledById",
242 column: x => x.CancelledById,
243 principalTable:
"Users",
244 principalColumn:
"Id",
245 onDelete: ReferentialAction.Restrict);
247 name:
"FK_Jobs_Instances_InstanceId",
248 column: x => x.InstanceId,
249 principalTable:
"Instances",
250 principalColumn:
"Id",
251 onDelete: ReferentialAction.Cascade);
253 name:
"FK_Jobs_Users_StartedById",
254 column: x => x.StartedById,
255 principalTable:
"Users",
256 principalColumn:
"Id",
257 onDelete: ReferentialAction.Cascade);
260 migrationBuilder.CreateTable(
261 name:
"ChatChannels",
262 columns: table =>
new
264 Id = table.Column<
long>(nullable:
false)
265 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
266 IrcChannel = table.Column<
string>(maxLength: 100, nullable:
true),
267 DiscordChannelId = table.Column<decimal>(nullable:
true),
268 IsAdminChannel = table.Column<
bool>(nullable:
false),
269 IsWatchdogChannel = table.Column<
bool>(nullable:
false),
270 IsUpdatesChannel = table.Column<
bool>(nullable:
false),
271 Tag = table.Column<
string>(maxLength: 10000, nullable:
true),
272 ChatSettingsId = table.Column<
long>(nullable:
false),
274 constraints: table =>
276 table.PrimaryKey(
"PK_ChatChannels", x => x.Id);
278 name:
"FK_ChatChannels_ChatBots_ChatSettingsId",
279 column: x => x.ChatSettingsId,
280 principalTable:
"ChatBots",
281 principalColumn:
"Id",
282 onDelete: ReferentialAction.Cascade);
285 migrationBuilder.CreateTable(
287 columns: table =>
new
289 Id = table.Column<
long>(nullable:
false)
290 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
291 Number = table.Column<
int>(nullable:
false),
292 PullRequestRevision = table.Column<
string>(maxLength: 40, nullable:
false),
293 Comment = table.Column<
string>(maxLength: 10000, nullable:
true),
294 TitleAtMerge = table.Column<
string>(nullable:
false),
295 BodyAtMerge = table.Column<
string>(nullable:
false),
296 Url = table.Column<
string>(nullable:
false),
297 Author = table.Column<
string>(nullable:
false),
298 MergedAt = table.Column<DateTimeOffset>(nullable:
false),
299 MergedById = table.Column<
long>(nullable:
false),
300 PrimaryRevisionInformationId = table.Column<
long>(nullable:
false),
302 constraints: table =>
304 table.PrimaryKey(
"PK_TestMerges", x => x.Id);
306 name:
"FK_TestMerges_Users_MergedById",
307 column: x => x.MergedById,
308 principalTable:
"Users",
309 principalColumn:
"Id",
310 onDelete: ReferentialAction.Restrict);
312 name:
"FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId",
313 column: x => x.PrimaryRevisionInformationId,
314 principalTable:
"RevisionInformations",
315 principalColumn:
"Id",
316 onDelete: ReferentialAction.Cascade);
319 migrationBuilder.CreateTable(
321 columns: table =>
new
323 Id = table.Column<
long>(nullable:
false)
324 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
325 DmeName = table.Column<
string>(nullable:
false),
326 Output = table.Column<
string>(nullable:
false),
327 DirectoryName = table.Column<Guid>(nullable:
false),
328 MinimumSecurityLevel = table.Column<
int>(nullable:
false),
329 JobId = table.Column<
long>(nullable:
false),
330 RevisionInformationId = table.Column<
long>(nullable:
false),
331 ByondVersion = table.Column<
string>(nullable:
false),
332 DMApiMajorVersion = table.Column<
int>(nullable:
true),
333 DMApiMinorVersion = table.Column<
int>(nullable:
true),
334 DMApiPatchVersion = table.Column<
int>(nullable:
true),
336 constraints: table =>
338 table.PrimaryKey(
"PK_CompileJobs", x => x.Id);
340 name:
"FK_CompileJobs_Jobs_JobId",
341 column: x => x.JobId,
342 principalTable:
"Jobs",
343 principalColumn:
"Id",
344 onDelete: ReferentialAction.Cascade);
346 name:
"FK_CompileJobs_RevisionInformations_RevisionInformationId",
347 column: x => x.RevisionInformationId,
348 principalTable:
"RevisionInformations",
349 principalColumn:
"Id",
350 onDelete: ReferentialAction.Cascade);
353 migrationBuilder.CreateTable(
354 name:
"RevInfoTestMerges",
355 columns: table =>
new
357 Id = table.Column<
long>(nullable:
false)
358 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
359 TestMergeId = table.Column<
long>(nullable:
false),
360 RevisionInformationId = table.Column<
long>(nullable:
false),
362 constraints: table =>
364 table.PrimaryKey(
"PK_RevInfoTestMerges", x => x.Id);
366 name:
"FK_RevInfoTestMerges_RevisionInformations_RevisionInformationId",
367 column: x => x.RevisionInformationId,
368 principalTable:
"RevisionInformations",
369 principalColumn:
"Id",
370 onDelete: ReferentialAction.Cascade);
372 name:
"FK_RevInfoTestMerges_TestMerges_TestMergeId",
373 column: x => x.TestMergeId,
374 principalTable:
"TestMerges",
375 principalColumn:
"Id");
378 migrationBuilder.CreateTable(
379 name:
"ReattachInformations",
380 columns: table =>
new
382 Id = table.Column<
long>(nullable:
false)
383 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
384 AccessIdentifier = table.Column<
string>(nullable:
false),
385 ProcessId = table.Column<
int>(nullable:
false),
386 IsPrimary = table.Column<
bool>(nullable:
false),
387 Port = table.Column<
int>(nullable:
false),
388 RebootState = table.Column<
int>(nullable:
false),
389 LaunchSecurityLevel = table.Column<
int>(nullable:
false),
390 CompileJobId = table.Column<
long>(nullable:
false),
392 constraints: table =>
394 table.PrimaryKey(
"PK_ReattachInformations", x => x.Id);
396 name:
"FK_ReattachInformations_CompileJobs_CompileJobId",
397 column: x => x.CompileJobId,
398 principalTable:
"CompileJobs",
399 principalColumn:
"Id",
400 onDelete: ReferentialAction.Cascade);
403 migrationBuilder.CreateTable(
404 name:
"WatchdogReattachInformations",
405 columns: table =>
new
407 Id = table.Column<
long>(nullable:
false)
408 .Annotation(
"Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
409 AlphaIsActive = table.Column<
bool>(nullable:
false),
410 InstanceId = table.Column<
long>(nullable:
false),
411 AlphaId = table.Column<
long>(nullable:
true),
412 BravoId = table.Column<
long>(nullable:
true),
414 constraints: table =>
416 table.PrimaryKey(
"PK_WatchdogReattachInformations", x => x.Id);
418 name:
"FK_WatchdogReattachInformations_ReattachInformations_AlphaId",
419 column: x => x.AlphaId,
420 principalTable:
"ReattachInformations",
421 principalColumn:
"Id",
422 onDelete: ReferentialAction.Restrict);
424 name:
"FK_WatchdogReattachInformations_ReattachInformations_BravoId",
425 column: x => x.BravoId,
426 principalTable:
"ReattachInformations",
427 principalColumn:
"Id",
428 onDelete: ReferentialAction.Restrict);
430 name:
"FK_WatchdogReattachInformations_Instances_InstanceId",
431 column: x => x.InstanceId,
432 principalTable:
"Instances",
433 principalColumn:
"Id",
434 onDelete: ReferentialAction.Cascade);
437 migrationBuilder.CreateIndex(
438 name:
"IX_ChatBots_InstanceId_Name",
440 columns:
new[] {
"InstanceId",
"Name" },
443 migrationBuilder.CreateIndex(
444 name:
"IX_ChatChannels_ChatSettingsId_DiscordChannelId",
445 table:
"ChatChannels",
446 columns:
new[] {
"ChatSettingsId",
"DiscordChannelId" },
449 migrationBuilder.CreateIndex(
450 name:
"IX_ChatChannels_ChatSettingsId_IrcChannel",
451 table:
"ChatChannels",
452 columns:
new[] {
"ChatSettingsId",
"IrcChannel" },
455 migrationBuilder.CreateIndex(
456 name:
"IX_CompileJobs_DirectoryName",
457 table:
"CompileJobs",
458 column:
"DirectoryName");
460 migrationBuilder.CreateIndex(
461 name:
"IX_CompileJobs_JobId",
462 table:
"CompileJobs",
466 migrationBuilder.CreateIndex(
467 name:
"IX_CompileJobs_RevisionInformationId",
468 table:
"CompileJobs",
469 column:
"RevisionInformationId");
471 migrationBuilder.CreateIndex(
472 name:
"IX_DreamDaemonSettings_InstanceId",
473 table:
"DreamDaemonSettings",
474 column:
"InstanceId",
477 migrationBuilder.CreateIndex(
478 name:
"IX_DreamMakerSettings_InstanceId",
479 table:
"DreamMakerSettings",
480 column:
"InstanceId",
483 migrationBuilder.CreateIndex(
484 name:
"IX_Instances_Path",
489 migrationBuilder.CreateIndex(
490 name:
"IX_InstanceUsers_InstanceId",
491 table:
"InstanceUsers",
492 column:
"InstanceId");
494 migrationBuilder.CreateIndex(
495 name:
"IX_InstanceUsers_UserId_InstanceId",
496 table:
"InstanceUsers",
497 columns:
new[] {
"UserId",
"InstanceId" },
500 migrationBuilder.CreateIndex(
501 name:
"IX_Jobs_CancelledById",
503 column:
"CancelledById");
505 migrationBuilder.CreateIndex(
506 name:
"IX_Jobs_InstanceId",
508 column:
"InstanceId");
510 migrationBuilder.CreateIndex(
511 name:
"IX_Jobs_StartedById",
513 column:
"StartedById");
515 migrationBuilder.CreateIndex(
516 name:
"IX_ReattachInformations_CompileJobId",
517 table:
"ReattachInformations",
518 column:
"CompileJobId");
520 migrationBuilder.CreateIndex(
521 name:
"IX_RepositorySettings_InstanceId",
522 table:
"RepositorySettings",
523 column:
"InstanceId",
526 migrationBuilder.CreateIndex(
527 name:
"IX_RevInfoTestMerges_RevisionInformationId",
528 table:
"RevInfoTestMerges",
529 column:
"RevisionInformationId");
531 migrationBuilder.CreateIndex(
532 name:
"IX_RevInfoTestMerges_TestMergeId",
533 table:
"RevInfoTestMerges",
534 column:
"TestMergeId");
536 migrationBuilder.CreateIndex(
537 name:
"IX_RevisionInformations_InstanceId_CommitSha",
538 table:
"RevisionInformations",
539 columns:
new[] {
"InstanceId",
"CommitSha" },
542 migrationBuilder.CreateIndex(
543 name:
"IX_TestMerges_MergedById",
545 column:
"MergedById");
547 migrationBuilder.CreateIndex(
548 name:
"IX_TestMerges_PrimaryRevisionInformationId",
550 column:
"PrimaryRevisionInformationId",
553 migrationBuilder.CreateIndex(
554 name:
"IX_Users_CanonicalName",
556 column:
"CanonicalName",
559 migrationBuilder.CreateIndex(
560 name:
"IX_Users_CreatedById",
562 column:
"CreatedById");
564 migrationBuilder.CreateIndex(
565 name:
"IX_Users_SystemIdentifier",
567 column:
"SystemIdentifier",
570 migrationBuilder.CreateIndex(
571 name:
"IX_WatchdogReattachInformations_AlphaId",
572 table:
"WatchdogReattachInformations",
575 migrationBuilder.CreateIndex(
576 name:
"IX_WatchdogReattachInformations_BravoId",
577 table:
"WatchdogReattachInformations",
580 migrationBuilder.CreateIndex(
581 name:
"IX_WatchdogReattachInformations_InstanceId",
582 table:
"WatchdogReattachInformations",
583 column:
"InstanceId",