15 protected override void Up(MigrationBuilder migrationBuilder)
17 ArgumentNullException.ThrowIfNull(migrationBuilder);
19 migrationBuilder.CreateTable(
23 Id = table.Column<
long>(nullable:
false)
24 .Annotation(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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<decimal>(nullable:
false),
30 InstanceManagerRights = table.Column<decimal>(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<decimal>(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(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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<
int>(nullable:
false),
77 RebootState = table.Column<
int>(nullable:
false),
78 Id = table.Column<
long>(nullable:
false)
79 .Annotation(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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<
long>(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_WatchdogReattachInformationId",
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(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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<
int>(nullable:
false),
168 SecondaryPort = table.Column<
int>(nullable:
false),
169 StartupTimeout = table.Column<
long>(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(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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<
int>(nullable:
false),
196 Id = table.Column<
long>(nullable:
false)
197 .Annotation(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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<decimal>(nullable:
false),
217 ByondRights = table.Column<decimal>(nullable:
false),
218 DreamDaemonRights = table.Column<decimal>(nullable:
false),
219 DreamMakerRights = table.Column<decimal>(nullable:
false),
220 RepositoryRights = table.Column<decimal>(nullable:
false),
221 ChatBotRights = table.Column<decimal>(nullable:
false),
222 ConfigurationRights = table.Column<decimal>(nullable:
false),
223 Id = table.Column<
long>(nullable:
false)
224 .Annotation(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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<decimal>(nullable:
true),
256 CancelRight = table.Column<decimal>(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(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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(
"SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.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" },
438 filter:
"[DiscordChannelId] IS NOT NULL");
440 migrationBuilder.CreateIndex(
441 name:
"IX_ChatChannels_ChatSettingsId_IrcChannel",
442 table:
"ChatChannels",
443 columns:
new[] {
"ChatSettingsId",
"IrcChannel" },
445 filter:
"[IrcChannel] IS NOT NULL");
447 migrationBuilder.CreateIndex(
448 name:
"IX_CompileJobs_DirectoryName",
449 table:
"CompileJobs",
450 column:
"DirectoryName");
452 migrationBuilder.CreateIndex(
453 name:
"IX_CompileJobs_JobId",
454 table:
"CompileJobs",
457 migrationBuilder.CreateIndex(
458 name:
"IX_CompileJobs_RevisionInformationId",
459 table:
"CompileJobs",
460 column:
"RevisionInformationId");
462 migrationBuilder.CreateIndex(
463 name:
"IX_DreamDaemonSettings_InstanceId",
464 table:
"DreamDaemonSettings",
465 column:
"InstanceId",
468 migrationBuilder.CreateIndex(
469 name:
"IX_DreamMakerSettings_InstanceId",
470 table:
"DreamMakerSettings",
471 column:
"InstanceId",
474 migrationBuilder.CreateIndex(
475 name:
"IX_Instances_Path",
480 migrationBuilder.CreateIndex(
481 name:
"IX_Instances_WatchdogReattachInformationId",
483 column:
"WatchdogReattachInformationId");
485 migrationBuilder.CreateIndex(
486 name:
"IX_InstanceUsers_InstanceId",
487 table:
"InstanceUsers",
488 column:
"InstanceId");
490 migrationBuilder.CreateIndex(
491 name:
"IX_InstanceUsers_UserId_InstanceId",
492 table:
"InstanceUsers",
493 columns:
new[] {
"UserId",
"InstanceId" },
496 migrationBuilder.CreateIndex(
497 name:
"IX_Jobs_CancelledById",
499 column:
"CancelledById");
501 migrationBuilder.CreateIndex(
502 name:
"IX_Jobs_InstanceId",
504 column:
"InstanceId");
506 migrationBuilder.CreateIndex(
507 name:
"IX_Jobs_StartedById",
509 column:
"StartedById");
511 migrationBuilder.CreateIndex(
512 name:
"IX_ReattachInformations_CompileJobId",
513 table:
"ReattachInformations",
514 column:
"CompileJobId");
516 migrationBuilder.CreateIndex(
517 name:
"IX_RepositorySettings_InstanceId",
518 table:
"RepositorySettings",
519 column:
"InstanceId",
522 migrationBuilder.CreateIndex(
523 name:
"IX_RevInfoTestMerges_RevisionInformationId",
524 table:
"RevInfoTestMerges",
525 column:
"RevisionInformationId");
527 migrationBuilder.CreateIndex(
528 name:
"IX_RevInfoTestMerges_TestMergeId",
529 table:
"RevInfoTestMerges",
530 column:
"TestMergeId");
532 migrationBuilder.CreateIndex(
533 name:
"IX_RevisionInformations_CommitSha",
534 table:
"RevisionInformations",
538 migrationBuilder.CreateIndex(
539 name:
"IX_RevisionInformations_InstanceId",
540 table:
"RevisionInformations",
541 column:
"InstanceId");
543 migrationBuilder.CreateIndex(
544 name:
"IX_TestMerges_MergedById",
546 column:
"MergedById");
548 migrationBuilder.CreateIndex(
549 name:
"IX_TestMerges_PrimaryRevisionInformationId",
551 column:
"PrimaryRevisionInformationId",
553 filter:
"[PrimaryRevisionInformationId] IS NOT NULL");
555 migrationBuilder.CreateIndex(
556 name:
"IX_Users_CanonicalName",
558 column:
"CanonicalName",
561 migrationBuilder.CreateIndex(
562 name:
"IX_Users_CreatedById",
564 column:
"CreatedById");
566 migrationBuilder.CreateIndex(
567 name:
"IX_WatchdogReattachInformations_AlphaId",
568 table:
"WatchdogReattachInformations",
571 migrationBuilder.CreateIndex(
572 name:
"IX_WatchdogReattachInformations_BravoId",
573 table:
"WatchdogReattachInformations",
576 migrationBuilder.AddForeignKey(
577 name:
"FK_ChatChannels_ChatBots_ChatSettingsId",
578 table:
"ChatChannels",
579 column:
"ChatSettingsId",
580 principalTable:
"ChatBots",
581 principalColumn:
"Id",
582 onDelete: ReferentialAction.Cascade);
584 migrationBuilder.AddForeignKey(
585 name:
"FK_ReattachInformations_CompileJobs_CompileJobId",
586 table:
"ReattachInformations",
587 column:
"CompileJobId",
588 principalTable:
"CompileJobs",
589 principalColumn:
"Id",
590 onDelete: ReferentialAction.Restrict);