15 protected override void Up(MigrationBuilder migrationBuilder)
17 ArgumentNullException.ThrowIfNull(migrationBuilder);
19 migrationBuilder.CreateTable(
23 Id = table.Column<
long>(nullable:
false)
24 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
25 Enabled = table.Column<
bool>(nullable:
false),
26 CreatedAt = table.Column<DateTimeOffset>(nullable:
false),
27 SystemIdentifier = table.Column<
string>(nullable:
true),
28 Name = table.Column<
string>(nullable:
false),
29 AdministrationRights = table.Column<ulong>(nullable:
false),
30 InstanceManagerRights = table.Column<ulong>(nullable:
false),
31 PasswordHash = table.Column<
string>(nullable:
true),
32 CreatedById = table.Column<
long>(nullable:
true),
33 CanonicalName = table.Column<
string>(nullable:
false),
34 LastPasswordUpdate = table.Column<DateTimeOffset>(nullable:
true),
38 table.PrimaryKey(
"PK_Users", x => x.Id);
40 name:
"FK_Users_Users_CreatedById",
41 column: x => x.CreatedById,
42 principalTable:
"Users",
43 principalColumn:
"Id",
44 onDelete: ReferentialAction.Restrict);
47 migrationBuilder.CreateTable(
51 IrcChannel = table.Column<
string>(nullable:
true),
52 DiscordChannelId = table.Column<ulong>(nullable:
true),
53 IsAdminChannel = table.Column<
bool>(nullable:
false),
54 IsWatchdogChannel = table.Column<
bool>(nullable:
false),
55 IsUpdatesChannel = table.Column<
bool>(nullable:
false),
56 Tag = table.Column<
string>(nullable:
true),
57 Id = table.Column<
long>(nullable:
false)
58 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
59 ChatSettingsId = table.Column<
long>(nullable:
false),
63 table.PrimaryKey(
"PK_ChatChannels", x => x.Id);
66 migrationBuilder.CreateTable(
67 name:
"ReattachInformations",
70 ChatCommandsJson = table.Column<
string>(nullable:
false),
71 ChatChannelsJson = table.Column<
string>(nullable:
false),
72 ServerCommandsJson = table.Column<
string>(nullable:
false),
73 AccessIdentifier = table.Column<
string>(nullable:
false),
74 ProcessId = table.Column<
int>(nullable:
false),
75 IsPrimary = table.Column<
bool>(nullable:
false),
76 Port = table.Column<ushort>(nullable:
false),
77 RebootState = table.Column<
int>(nullable:
false),
78 Id = table.Column<
long>(nullable:
false)
79 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
80 CompileJobId = table.Column<
long>(nullable:
true),
84 table.PrimaryKey(
"PK_ReattachInformations", x => x.Id);
87 migrationBuilder.CreateTable(
88 name:
"WatchdogReattachInformations",
91 AlphaIsActive = table.Column<
bool>(nullable:
false),
92 Id = table.Column<
long>(nullable:
false)
93 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
94 AlphaId = table.Column<
long>(nullable:
true),
95 BravoId = table.Column<
long>(nullable:
true),
99 table.PrimaryKey(
"PK_WatchdogReattachInformations", x => x.Id);
101 name:
"FK_WatchdogReattachInformations_ReattachInformations_AlphaId",
102 column: x => x.AlphaId,
103 principalTable:
"ReattachInformations",
104 principalColumn:
"Id",
105 onDelete: ReferentialAction.Restrict);
107 name:
"FK_WatchdogReattachInformations_ReattachInformations_BravoId",
108 column: x => x.BravoId,
109 principalTable:
"ReattachInformations",
110 principalColumn:
"Id",
111 onDelete: ReferentialAction.Restrict);
114 migrationBuilder.CreateTable(
116 columns: table =>
new
118 Id = table.Column<
long>(nullable:
false)
119 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
120 Name = table.Column<
string>(nullable:
false),
121 Path = table.Column<
string>(nullable:
false),
122 Online = table.Column<
bool>(nullable:
false),
123 ConfigurationType = table.Column<
int>(nullable:
false),
124 AutoUpdateInterval = table.Column<uint>(nullable:
false),
125 WatchdogReattachInformationId = table.Column<
long>(nullable:
true),
127 constraints: table =>
129 table.PrimaryKey(
"PK_Instances", x => x.Id);
131 name:
"FK_Instances_WatchdogReattachInformations_WatchdogReattachInfor~",
132 column: x => x.WatchdogReattachInformationId,
133 principalTable:
"WatchdogReattachInformations",
134 principalColumn:
"Id",
135 onDelete: ReferentialAction.Restrict);
138 migrationBuilder.CreateTable(
140 columns: table =>
new
142 Id = table.Column<
long>(nullable:
false)
143 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
144 Name = table.Column<
string>(nullable:
false),
145 Enabled = table.Column<
bool>(nullable:
true),
146 Provider = table.Column<
int>(nullable:
true),
147 ConnectionString = table.Column<
string>(nullable:
false),
148 InstanceId = table.Column<
long>(nullable:
false),
150 constraints: table =>
152 table.PrimaryKey(
"PK_ChatBots", x => x.Id);
154 name:
"FK_ChatBots_Instances_InstanceId",
155 column: x => x.InstanceId,
156 principalTable:
"Instances",
157 principalColumn:
"Id",
158 onDelete: ReferentialAction.Cascade);
161 migrationBuilder.CreateTable(
162 name:
"DreamDaemonSettings",
163 columns: table =>
new
165 AllowWebClient = table.Column<
bool>(nullable:
false),
166 SecurityLevel = table.Column<
int>(nullable:
false),
167 PrimaryPort = table.Column<ushort>(nullable:
false),
168 SecondaryPort = table.Column<ushort>(nullable:
false),
169 StartupTimeout = table.Column<uint>(nullable:
false),
170 AutoStart = table.Column<
bool>(nullable:
false),
171 SoftRestart = table.Column<
bool>(nullable:
false),
172 SoftShutdown = table.Column<
bool>(nullable:
false),
173 Id = table.Column<
long>(nullable:
false)
174 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
175 ProcessId = table.Column<
int>(nullable:
true),
176 AccessToken = table.Column<
string>(nullable:
true),
177 InstanceId = table.Column<
long>(nullable:
false),
179 constraints: table =>
181 table.PrimaryKey(
"PK_DreamDaemonSettings", x => x.Id);
183 name:
"FK_DreamDaemonSettings_Instances_InstanceId",
184 column: x => x.InstanceId,
185 principalTable:
"Instances",
186 principalColumn:
"Id",
187 onDelete: ReferentialAction.Cascade);
190 migrationBuilder.CreateTable(
191 name:
"DreamMakerSettings",
192 columns: table =>
new
194 ProjectName = table.Column<
string>(nullable:
true),
195 ApiValidationPort = table.Column<ushort>(nullable:
false),
196 Id = table.Column<
long>(nullable:
false)
197 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
198 InstanceId = table.Column<
long>(nullable:
false),
200 constraints: table =>
202 table.PrimaryKey(
"PK_DreamMakerSettings", x => x.Id);
204 name:
"FK_DreamMakerSettings_Instances_InstanceId",
205 column: x => x.InstanceId,
206 principalTable:
"Instances",
207 principalColumn:
"Id",
208 onDelete: ReferentialAction.Cascade);
211 migrationBuilder.CreateTable(
212 name:
"InstanceUsers",
213 columns: table =>
new
215 UserId = table.Column<
long>(nullable:
false),
216 InstanceUserRights = table.Column<ulong>(nullable:
false),
217 ByondRights = table.Column<ulong>(nullable:
false),
218 DreamDaemonRights = table.Column<ulong>(nullable:
false),
219 DreamMakerRights = table.Column<ulong>(nullable:
false),
220 RepositoryRights = table.Column<ulong>(nullable:
false),
221 ChatBotRights = table.Column<ulong>(nullable:
false),
222 ConfigurationRights = table.Column<ulong>(nullable:
false),
223 Id = table.Column<
long>(nullable:
false)
224 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
225 InstanceId = table.Column<
long>(nullable:
false),
227 constraints: table =>
229 table.PrimaryKey(
"PK_InstanceUsers", x => x.Id);
231 name:
"FK_InstanceUsers_Instances_InstanceId",
232 column: x => x.InstanceId,
233 principalTable:
"Instances",
234 principalColumn:
"Id",
235 onDelete: ReferentialAction.Cascade);
237 name:
"FK_InstanceUsers_Users_UserId",
238 column: x => x.UserId,
239 principalTable:
"Users",
240 principalColumn:
"Id",
241 onDelete: ReferentialAction.Cascade);
244 migrationBuilder.CreateTable(
246 columns: table =>
new
248 Id = table.Column<
long>(nullable:
false)
249 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
250 Description = table.Column<
string>(nullable:
false),
251 ExceptionDetails = table.Column<
string>(nullable:
true),
252 StartedAt = table.Column<DateTimeOffset>(nullable:
false),
253 StoppedAt = table.Column<DateTimeOffset>(nullable:
true),
254 Cancelled = table.Column<
bool>(nullable:
false),
255 CancelRightsType = table.Column<ulong>(nullable:
true),
256 CancelRight = table.Column<ulong>(nullable:
true),
257 StartedById = table.Column<
long>(nullable:
false),
258 CancelledById = table.Column<
long>(nullable:
true),
259 InstanceId = table.Column<
long>(nullable:
false),
261 constraints: table =>
263 table.PrimaryKey(
"PK_Jobs", x => x.Id);
265 name:
"FK_Jobs_Users_CancelledById",
266 column: x => x.CancelledById,
267 principalTable:
"Users",
268 principalColumn:
"Id",
269 onDelete: ReferentialAction.Restrict);
271 name:
"FK_Jobs_Instances_InstanceId",
272 column: x => x.InstanceId,
273 principalTable:
"Instances",
274 principalColumn:
"Id",
275 onDelete: ReferentialAction.Cascade);
277 name:
"FK_Jobs_Users_StartedById",
278 column: x => x.StartedById,
279 principalTable:
"Users",
280 principalColumn:
"Id",
281 onDelete: ReferentialAction.Cascade);
284 migrationBuilder.CreateTable(
285 name:
"RepositorySettings",
286 columns: table =>
new
288 CommitterName = table.Column<
string>(nullable:
false),
289 CommitterEmail = table.Column<
string>(nullable:
false),
290 AccessUser = table.Column<
string>(nullable:
true),
291 AccessToken = table.Column<
string>(nullable:
true),
292 PushTestMergeCommits = table.Column<
bool>(nullable:
false),
293 ShowTestMergeCommitters = table.Column<
bool>(nullable:
false),
294 AutoUpdatesKeepTestMerges = table.Column<
bool>(nullable:
false),
295 AutoUpdatesSynchronize = table.Column<
bool>(nullable:
false),
296 Id = table.Column<
long>(nullable:
false)
297 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
298 InstanceId = table.Column<
long>(nullable:
false),
300 constraints: table =>
302 table.PrimaryKey(
"PK_RepositorySettings", x => x.Id);
304 name:
"FK_RepositorySettings_Instances_InstanceId",
305 column: x => x.InstanceId,
306 principalTable:
"Instances",
307 principalColumn:
"Id",
308 onDelete: ReferentialAction.Cascade);
311 migrationBuilder.CreateTable(
312 name:
"RevisionInformations",
313 columns: table =>
new
315 CommitSha = table.Column<
string>(maxLength: 40, nullable:
false),
316 OriginCommitSha = table.Column<
string>(maxLength: 40, nullable:
false),
317 Id = table.Column<
long>(nullable:
false)
318 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
319 InstanceId = table.Column<
long>(nullable:
false),
321 constraints: table =>
323 table.PrimaryKey(
"PK_RevisionInformations", x => x.Id);
325 name:
"FK_RevisionInformations_Instances_InstanceId",
326 column: x => x.InstanceId,
327 principalTable:
"Instances",
328 principalColumn:
"Id",
329 onDelete: ReferentialAction.Cascade);
332 migrationBuilder.CreateTable(
334 columns: table =>
new
336 Id = table.Column<
long>(nullable:
false)
337 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
338 DmeName = table.Column<
string>(nullable:
true),
339 Output = table.Column<
string>(nullable:
true),
340 DirectoryName = table.Column<Guid>(nullable:
true),
341 JobId = table.Column<
long>(nullable:
true),
342 RevisionInformationId = table.Column<
long>(nullable:
false),
343 ByondVersion = table.Column<
string>(nullable:
false),
345 constraints: table =>
347 table.PrimaryKey(
"PK_CompileJobs", x => x.Id);
349 name:
"FK_CompileJobs_Jobs_JobId",
350 column: x => x.JobId,
351 principalTable:
"Jobs",
352 principalColumn:
"Id",
353 onDelete: ReferentialAction.Restrict);
355 name:
"FK_CompileJobs_RevisionInformations_RevisionInformationId",
356 column: x => x.RevisionInformationId,
357 principalTable:
"RevisionInformations",
358 principalColumn:
"Id",
359 onDelete: ReferentialAction.Cascade);
362 migrationBuilder.CreateTable(
364 columns: table =>
new
366 Number = table.Column<
int>(nullable:
false),
367 PullRequestRevision = table.Column<
string>(nullable:
false),
368 Comment = table.Column<
string>(nullable:
true),
369 TitleAtMerge = table.Column<
string>(nullable:
false),
370 BodyAtMerge = table.Column<
string>(nullable:
false),
371 Url = table.Column<
string>(nullable:
false),
372 Author = table.Column<
string>(nullable:
false),
373 Id = table.Column<
long>(nullable:
false)
374 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
375 MergedAt = table.Column<DateTimeOffset>(nullable:
false),
376 MergedById = table.Column<
long>(nullable:
false),
377 PrimaryRevisionInformationId = table.Column<
long>(nullable:
true),
379 constraints: table =>
381 table.PrimaryKey(
"PK_TestMerges", x => x.Id);
383 name:
"FK_TestMerges_Users_MergedById",
384 column: x => x.MergedById,
385 principalTable:
"Users",
386 principalColumn:
"Id",
387 onDelete: ReferentialAction.Restrict);
389 name:
"FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId",
390 column: x => x.PrimaryRevisionInformationId,
391 principalTable:
"RevisionInformations",
392 principalColumn:
"Id",
393 onDelete: ReferentialAction.SetNull);
396 migrationBuilder.CreateTable(
397 name:
"RevInfoTestMerges",
398 columns: table =>
new
400 Id = table.Column<
long>(nullable:
false)
401 .Annotation(
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
402 TestMergeId = table.Column<
long>(nullable:
false),
403 RevisionInformationId = table.Column<
long>(nullable:
false),
405 constraints: table =>
407 table.PrimaryKey(
"PK_RevInfoTestMerges", x => x.Id);
409 name:
"FK_RevInfoTestMerges_RevisionInformations_RevisionInformationId",
410 column: x => x.RevisionInformationId,
411 principalTable:
"RevisionInformations",
412 principalColumn:
"Id",
413 onDelete: ReferentialAction.Cascade);
415 name:
"FK_RevInfoTestMerges_TestMerges_TestMergeId",
416 column: x => x.TestMergeId,
417 principalTable:
"TestMerges",
418 principalColumn:
"Id",
419 onDelete: ReferentialAction.Cascade);
422 migrationBuilder.CreateIndex(
423 name:
"IX_ChatBots_InstanceId",
425 column:
"InstanceId");
427 migrationBuilder.CreateIndex(
428 name:
"IX_ChatBots_Name",
433 migrationBuilder.CreateIndex(
434 name:
"IX_ChatChannels_ChatSettingsId_DiscordChannelId",
435 table:
"ChatChannels",
436 columns:
new[] {
"ChatSettingsId",
"DiscordChannelId" },
439 migrationBuilder.CreateIndex(
440 name:
"IX_ChatChannels_ChatSettingsId_IrcChannel",
441 table:
"ChatChannels",
442 columns:
new[] {
"ChatSettingsId",
"IrcChannel" },
445 migrationBuilder.CreateIndex(
446 name:
"IX_CompileJobs_DirectoryName",
447 table:
"CompileJobs",
448 column:
"DirectoryName");
450 migrationBuilder.CreateIndex(
451 name:
"IX_CompileJobs_JobId",
452 table:
"CompileJobs",
455 migrationBuilder.CreateIndex(
456 name:
"IX_CompileJobs_RevisionInformationId",
457 table:
"CompileJobs",
458 column:
"RevisionInformationId");
460 migrationBuilder.CreateIndex(
461 name:
"IX_DreamDaemonSettings_InstanceId",
462 table:
"DreamDaemonSettings",
463 column:
"InstanceId",
466 migrationBuilder.CreateIndex(
467 name:
"IX_DreamMakerSettings_InstanceId",
468 table:
"DreamMakerSettings",
469 column:
"InstanceId",
472 migrationBuilder.CreateIndex(
473 name:
"IX_Instances_Path",
478 migrationBuilder.CreateIndex(
479 name:
"IX_Instances_WatchdogReattachInformationId",
481 column:
"WatchdogReattachInformationId");
483 migrationBuilder.CreateIndex(
484 name:
"IX_InstanceUsers_InstanceId",
485 table:
"InstanceUsers",
486 column:
"InstanceId");
488 migrationBuilder.CreateIndex(
489 name:
"IX_InstanceUsers_UserId_InstanceId",
490 table:
"InstanceUsers",
491 columns:
new[] {
"UserId",
"InstanceId" },
494 migrationBuilder.CreateIndex(
495 name:
"IX_Jobs_CancelledById",
497 column:
"CancelledById");
499 migrationBuilder.CreateIndex(
500 name:
"IX_Jobs_InstanceId",
502 column:
"InstanceId");
504 migrationBuilder.CreateIndex(
505 name:
"IX_Jobs_StartedById",
507 column:
"StartedById");
509 migrationBuilder.CreateIndex(
510 name:
"IX_ReattachInformations_CompileJobId",
511 table:
"ReattachInformations",
512 column:
"CompileJobId");
514 migrationBuilder.CreateIndex(
515 name:
"IX_RepositorySettings_InstanceId",
516 table:
"RepositorySettings",
517 column:
"InstanceId",
520 migrationBuilder.CreateIndex(
521 name:
"IX_RevInfoTestMerges_RevisionInformationId",
522 table:
"RevInfoTestMerges",
523 column:
"RevisionInformationId");
525 migrationBuilder.CreateIndex(
526 name:
"IX_RevInfoTestMerges_TestMergeId",
527 table:
"RevInfoTestMerges",
528 column:
"TestMergeId");
530 migrationBuilder.CreateIndex(
531 name:
"IX_RevisionInformations_CommitSha",
532 table:
"RevisionInformations",
536 migrationBuilder.CreateIndex(
537 name:
"IX_RevisionInformations_InstanceId",
538 table:
"RevisionInformations",
539 column:
"InstanceId");
541 migrationBuilder.CreateIndex(
542 name:
"IX_TestMerges_MergedById",
544 column:
"MergedById");
546 migrationBuilder.CreateIndex(
547 name:
"IX_TestMerges_PrimaryRevisionInformationId",
549 column:
"PrimaryRevisionInformationId",
552 migrationBuilder.CreateIndex(
553 name:
"IX_Users_CanonicalName",
555 column:
"CanonicalName",
558 migrationBuilder.CreateIndex(
559 name:
"IX_Users_CreatedById",
561 column:
"CreatedById");
563 migrationBuilder.CreateIndex(
564 name:
"IX_WatchdogReattachInformations_AlphaId",
565 table:
"WatchdogReattachInformations",
568 migrationBuilder.CreateIndex(
569 name:
"IX_WatchdogReattachInformations_BravoId",
570 table:
"WatchdogReattachInformations",
573 migrationBuilder.AddForeignKey(
574 name:
"FK_ChatChannels_ChatBots_ChatSettingsId",
575 table:
"ChatChannels",
576 column:
"ChatSettingsId",
577 principalTable:
"ChatBots",
578 principalColumn:
"Id",
579 onDelete: ReferentialAction.Cascade);
581 migrationBuilder.AddForeignKey(
582 name:
"FK_ReattachInformations_CompileJobs_CompileJobId",
583 table:
"ReattachInformations",
584 column:
"CompileJobId",
585 principalTable:
"CompileJobs",
586 principalColumn:
"Id",
587 onDelete: ReferentialAction.Restrict);