tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
20200427180904_SLRebuild.cs
Go to the documentation of this file.
1using System;
2
3using Microsoft.EntityFrameworkCore.Migrations;
4
5#pragma warning disable CA1506
6
8{
12 public partial class SLRebuild : Migration
13 {
15 protected override void Up(MigrationBuilder migrationBuilder)
16 {
17 ArgumentNullException.ThrowIfNull(migrationBuilder);
18
19 migrationBuilder.CreateTable(
20 name: "Instances",
21 columns: table => new
22 {
23 Id = table.Column<long>(nullable: false)
24 .Annotation("Sqlite:Autoincrement", true),
25 Name = table.Column<string>(maxLength: 10000, nullable: false),
26 Path = table.Column<string>(nullable: false),
27 Online = table.Column<bool>(nullable: false),
28 ConfigurationType = table.Column<int>(nullable: false),
29 AutoUpdateInterval = table.Column<uint>(nullable: false),
30 ChatBotLimit = table.Column<ushort>(nullable: false),
31 },
32 constraints: table =>
33 {
34 table.PrimaryKey("PK_Instances", x => x.Id);
35 });
36
37 migrationBuilder.CreateTable(
38 name: "Users",
39 columns: table => new
40 {
41 Id = table.Column<long>(nullable: false)
42 .Annotation("Sqlite:Autoincrement", true),
43 Enabled = table.Column<bool>(nullable: false),
44 CreatedAt = table.Column<DateTimeOffset>(nullable: false),
45 SystemIdentifier = table.Column<string>(nullable: true),
46 Name = table.Column<string>(maxLength: 10000, nullable: false),
47 AdministrationRights = table.Column<ulong>(nullable: false),
48 InstanceManagerRights = table.Column<ulong>(nullable: false),
49 PasswordHash = table.Column<string>(nullable: true),
50 CreatedById = table.Column<long>(nullable: true),
51 CanonicalName = table.Column<string>(nullable: false),
52 LastPasswordUpdate = table.Column<DateTimeOffset>(nullable: true),
53 },
54 constraints: table =>
55 {
56 table.PrimaryKey("PK_Users", x => x.Id);
57 table.ForeignKey(
58 name: "FK_Users_Users_CreatedById",
59 column: x => x.CreatedById,
60 principalTable: "Users",
61 principalColumn: "Id",
62 onDelete: ReferentialAction.Restrict);
63 });
64
65 migrationBuilder.CreateTable(
66 name: "ChatBots",
67 columns: table => new
68 {
69 Id = table.Column<long>(nullable: false)
70 .Annotation("Sqlite:Autoincrement", true),
71 Name = table.Column<string>(maxLength: 100, nullable: false),
72 Enabled = table.Column<bool>(nullable: true),
73 ReconnectionInterval = table.Column<uint>(nullable: false),
74 ChannelLimit = table.Column<ushort>(nullable: false),
75 Provider = table.Column<int>(nullable: false),
76 ConnectionString = table.Column<string>(maxLength: 10000, nullable: false),
77 InstanceId = table.Column<long>(nullable: false),
78 },
79 constraints: table =>
80 {
81 table.PrimaryKey("PK_ChatBots", x => x.Id);
82 table.ForeignKey(
83 name: "FK_ChatBots_Instances_InstanceId",
84 column: x => x.InstanceId,
85 principalTable: "Instances",
86 principalColumn: "Id",
87 onDelete: ReferentialAction.Cascade);
88 });
89
90 migrationBuilder.CreateTable(
91 name: "DreamDaemonSettings",
92 columns: table => new
93 {
94 Id = table.Column<long>(nullable: false)
95 .Annotation("Sqlite:Autoincrement", true),
96 AllowWebClient = table.Column<bool>(nullable: false),
97 SecurityLevel = table.Column<int>(nullable: false),
98 PrimaryPort = table.Column<ushort>(nullable: false),
99 SecondaryPort = table.Column<ushort>(nullable: false),
100 StartupTimeout = table.Column<uint>(nullable: false),
101 AutoStart = table.Column<bool>(nullable: false),
102 SoftRestart = table.Column<bool>(nullable: false),
103 SoftShutdown = table.Column<bool>(nullable: false),
104 ProcessId = table.Column<int>(nullable: true),
105 AccessToken = table.Column<string>(nullable: true),
106 InstanceId = table.Column<long>(nullable: false),
107 },
108 constraints: table =>
109 {
110 table.PrimaryKey("PK_DreamDaemonSettings", x => x.Id);
111 table.ForeignKey(
112 name: "FK_DreamDaemonSettings_Instances_InstanceId",
113 column: x => x.InstanceId,
114 principalTable: "Instances",
115 principalColumn: "Id",
116 onDelete: ReferentialAction.Cascade);
117 });
118
119 migrationBuilder.CreateTable(
120 name: "DreamMakerSettings",
121 columns: table => new
122 {
123 Id = table.Column<long>(nullable: false)
124 .Annotation("Sqlite:Autoincrement", true),
125 ProjectName = table.Column<string>(maxLength: 10000, nullable: true),
126 ApiValidationPort = table.Column<ushort>(nullable: false),
127 ApiValidationSecurityLevel = table.Column<int>(nullable: false),
128 InstanceId = table.Column<long>(nullable: false),
129 },
130 constraints: table =>
131 {
132 table.PrimaryKey("PK_DreamMakerSettings", x => x.Id);
133 table.ForeignKey(
134 name: "FK_DreamMakerSettings_Instances_InstanceId",
135 column: x => x.InstanceId,
136 principalTable: "Instances",
137 principalColumn: "Id",
138 onDelete: ReferentialAction.Cascade);
139 });
140
141 migrationBuilder.CreateTable(
142 name: "RepositorySettings",
143 columns: table => new
144 {
145 Id = table.Column<long>(nullable: false)
146 .Annotation("Sqlite:Autoincrement", true),
147 CommitterName = table.Column<string>(maxLength: 10000, nullable: false),
148 CommitterEmail = table.Column<string>(maxLength: 10000, nullable: false),
149 AccessUser = table.Column<string>(maxLength: 10000, nullable: true),
150 AccessToken = table.Column<string>(maxLength: 10000, nullable: true),
151 PushTestMergeCommits = table.Column<bool>(nullable: false),
152 ShowTestMergeCommitters = table.Column<bool>(nullable: false),
153 AutoUpdatesKeepTestMerges = table.Column<bool>(nullable: false),
154 AutoUpdatesSynchronize = table.Column<bool>(nullable: false),
155 PostTestMergeComment = table.Column<bool>(nullable: false),
156 InstanceId = table.Column<long>(nullable: false),
157 },
158 constraints: table =>
159 {
160 table.PrimaryKey("PK_RepositorySettings", x => x.Id);
161 table.ForeignKey(
162 name: "FK_RepositorySettings_Instances_InstanceId",
163 column: x => x.InstanceId,
164 principalTable: "Instances",
165 principalColumn: "Id",
166 onDelete: ReferentialAction.Cascade);
167 });
168
169 migrationBuilder.CreateTable(
170 name: "RevisionInformations",
171 columns: table => new
172 {
173 Id = table.Column<long>(nullable: false)
174 .Annotation("Sqlite:Autoincrement", true),
175 CommitSha = table.Column<string>(maxLength: 40, nullable: false),
176 OriginCommitSha = table.Column<string>(maxLength: 40, nullable: false),
177 InstanceId = table.Column<long>(nullable: false),
178 },
179 constraints: table =>
180 {
181 table.PrimaryKey("PK_RevisionInformations", x => x.Id);
182 table.ForeignKey(
183 name: "FK_RevisionInformations_Instances_InstanceId",
184 column: x => x.InstanceId,
185 principalTable: "Instances",
186 principalColumn: "Id",
187 onDelete: ReferentialAction.Cascade);
188 });
189
190 migrationBuilder.CreateTable(
191 name: "InstanceUsers",
192 columns: table => new
193 {
194 Id = table.Column<long>(nullable: false)
195 .Annotation("Sqlite:Autoincrement", true),
196 UserId = table.Column<long>(nullable: false),
197 InstanceUserRights = table.Column<ulong>(nullable: false),
198 ByondRights = table.Column<ulong>(nullable: false),
199 DreamDaemonRights = table.Column<ulong>(nullable: false),
200 DreamMakerRights = table.Column<ulong>(nullable: false),
201 RepositoryRights = table.Column<ulong>(nullable: false),
202 ChatBotRights = table.Column<ulong>(nullable: false),
203 ConfigurationRights = table.Column<ulong>(nullable: false),
204 InstanceId = table.Column<long>(nullable: false),
205 },
206 constraints: table =>
207 {
208 table.PrimaryKey("PK_InstanceUsers", x => x.Id);
209 table.ForeignKey(
210 name: "FK_InstanceUsers_Instances_InstanceId",
211 column: x => x.InstanceId,
212 principalTable: "Instances",
213 principalColumn: "Id",
214 onDelete: ReferentialAction.Cascade);
215 table.ForeignKey(
216 name: "FK_InstanceUsers_Users_UserId",
217 column: x => x.UserId,
218 principalTable: "Users",
219 principalColumn: "Id",
220 onDelete: ReferentialAction.Cascade);
221 });
222
223 migrationBuilder.CreateTable(
224 name: "Jobs",
225 columns: table => new
226 {
227 Id = table.Column<long>(nullable: false)
228 .Annotation("Sqlite:Autoincrement", true),
229 Description = table.Column<string>(nullable: false),
230 ErrorCode = table.Column<uint>(nullable: true),
231 ExceptionDetails = table.Column<string>(nullable: true),
232 StartedAt = table.Column<DateTimeOffset>(nullable: false),
233 StoppedAt = table.Column<DateTimeOffset>(nullable: true),
234 Cancelled = table.Column<bool>(nullable: false),
235 CancelRightsType = table.Column<ulong>(nullable: true),
236 CancelRight = table.Column<ulong>(nullable: true),
237 StartedById = table.Column<long>(nullable: false),
238 CancelledById = table.Column<long>(nullable: true),
239 InstanceId = table.Column<long>(nullable: false),
240 },
241 constraints: table =>
242 {
243 table.PrimaryKey("PK_Jobs", x => x.Id);
244 table.ForeignKey(
245 name: "FK_Jobs_Users_CancelledById",
246 column: x => x.CancelledById,
247 principalTable: "Users",
248 principalColumn: "Id",
249 onDelete: ReferentialAction.Restrict);
250 table.ForeignKey(
251 name: "FK_Jobs_Instances_InstanceId",
252 column: x => x.InstanceId,
253 principalTable: "Instances",
254 principalColumn: "Id",
255 onDelete: ReferentialAction.Cascade);
256 table.ForeignKey(
257 name: "FK_Jobs_Users_StartedById",
258 column: x => x.StartedById,
259 principalTable: "Users",
260 principalColumn: "Id",
261 onDelete: ReferentialAction.Cascade);
262 });
263
264 migrationBuilder.CreateTable(
265 name: "ChatChannels",
266 columns: table => new
267 {
268 Id = table.Column<long>(nullable: false)
269 .Annotation("Sqlite:Autoincrement", true),
270 IrcChannel = table.Column<string>(maxLength: 100, nullable: true),
271 DiscordChannelId = table.Column<ulong>(nullable: true),
272 IsAdminChannel = table.Column<bool>(nullable: false),
273 IsWatchdogChannel = table.Column<bool>(nullable: false),
274 IsUpdatesChannel = table.Column<bool>(nullable: false),
275 Tag = table.Column<string>(maxLength: 10000, nullable: true),
276 ChatSettingsId = table.Column<long>(nullable: false),
277 },
278 constraints: table =>
279 {
280 table.PrimaryKey("PK_ChatChannels", x => x.Id);
281 table.ForeignKey(
282 name: "FK_ChatChannels_ChatBots_ChatSettingsId",
283 column: x => x.ChatSettingsId,
284 principalTable: "ChatBots",
285 principalColumn: "Id",
286 onDelete: ReferentialAction.Cascade);
287 });
288
289 migrationBuilder.CreateTable(
290 name: "TestMerges",
291 columns: table => new
292 {
293 Id = table.Column<long>(nullable: false)
294 .Annotation("Sqlite:Autoincrement", true),
295 Number = table.Column<int>(nullable: false),
296 PullRequestRevision = table.Column<string>(maxLength: 40, nullable: false),
297 Comment = table.Column<string>(maxLength: 10000, nullable: true),
298 TitleAtMerge = table.Column<string>(nullable: false),
299 BodyAtMerge = table.Column<string>(nullable: false),
300 Url = table.Column<string>(nullable: false),
301 Author = table.Column<string>(nullable: false),
302 MergedAt = table.Column<DateTimeOffset>(nullable: false),
303 MergedById = table.Column<long>(nullable: false),
304 PrimaryRevisionInformationId = table.Column<long>(nullable: false),
305 },
306 constraints: table =>
307 {
308 table.PrimaryKey("PK_TestMerges", x => x.Id);
309 table.ForeignKey(
310 name: "FK_TestMerges_Users_MergedById",
311 column: x => x.MergedById,
312 principalTable: "Users",
313 principalColumn: "Id",
314 onDelete: ReferentialAction.Restrict);
315 table.ForeignKey(
316 name: "FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId",
317 column: x => x.PrimaryRevisionInformationId,
318 principalTable: "RevisionInformations",
319 principalColumn: "Id",
320 onDelete: ReferentialAction.Cascade);
321 });
322
323 migrationBuilder.CreateTable(
324 name: "CompileJobs",
325 columns: table => new
326 {
327 Id = table.Column<long>(nullable: false)
328 .Annotation("Sqlite:Autoincrement", true),
329 DmeName = table.Column<string>(nullable: false),
330 Output = table.Column<string>(nullable: false),
331 DirectoryName = table.Column<Guid>(nullable: false),
332 MinimumSecurityLevel = table.Column<int>(nullable: false),
333 JobId = table.Column<long>(nullable: false),
334 RevisionInformationId = table.Column<long>(nullable: false),
335 ByondVersion = table.Column<string>(nullable: false),
336 DMApiMajorVersion = table.Column<int>(nullable: true),
337 DMApiMinorVersion = table.Column<int>(nullable: true),
338 DMApiPatchVersion = table.Column<int>(nullable: true),
339 },
340 constraints: table =>
341 {
342 table.PrimaryKey("PK_CompileJobs", x => x.Id);
343 table.ForeignKey(
344 name: "FK_CompileJobs_Jobs_JobId",
345 column: x => x.JobId,
346 principalTable: "Jobs",
347 principalColumn: "Id",
348 onDelete: ReferentialAction.Cascade);
349 table.ForeignKey(
350 name: "FK_CompileJobs_RevisionInformations_RevisionInformationId",
351 column: x => x.RevisionInformationId,
352 principalTable: "RevisionInformations",
353 principalColumn: "Id");
354 });
355
356 migrationBuilder.CreateTable(
357 name: "RevInfoTestMerges",
358 columns: table => new
359 {
360 Id = table.Column<long>(nullable: false)
361 .Annotation("Sqlite:Autoincrement", true),
362 TestMergeId = table.Column<long>(nullable: false),
363 RevisionInformationId = table.Column<long>(nullable: false),
364 },
365 constraints: table =>
366 {
367 table.PrimaryKey("PK_RevInfoTestMerges", x => x.Id);
368 table.ForeignKey(
369 name: "FK_RevInfoTestMerges_RevisionInformations_RevisionInformationId",
370 column: x => x.RevisionInformationId,
371 principalTable: "RevisionInformations",
372 principalColumn: "Id",
373 onDelete: ReferentialAction.Cascade);
374 table.ForeignKey(
375 name: "FK_RevInfoTestMerges_TestMerges_TestMergeId",
376 column: x => x.TestMergeId,
377 principalTable: "TestMerges",
378 principalColumn: "Id");
379 });
380
381 migrationBuilder.CreateTable(
382 name: "ReattachInformations",
383 columns: table => new
384 {
385 Id = table.Column<long>(nullable: false)
386 .Annotation("Sqlite:Autoincrement", true),
387 AccessIdentifier = table.Column<string>(nullable: false),
388 ProcessId = table.Column<int>(nullable: false),
389 IsPrimary = table.Column<bool>(nullable: false),
390 Port = table.Column<ushort>(nullable: false),
391 RebootState = table.Column<int>(nullable: false),
392 LaunchSecurityLevel = table.Column<int>(nullable: false),
393 CompileJobId = table.Column<long>(nullable: false),
394 },
395 constraints: table =>
396 {
397 table.PrimaryKey("PK_ReattachInformations", x => x.Id);
398 table.ForeignKey(
399 name: "FK_ReattachInformations_CompileJobs_CompileJobId",
400 column: x => x.CompileJobId,
401 principalTable: "CompileJobs",
402 principalColumn: "Id",
403 onDelete: ReferentialAction.Cascade);
404 });
405
406 migrationBuilder.CreateTable(
407 name: "WatchdogReattachInformations",
408 columns: table => new
409 {
410 Id = table.Column<long>(nullable: false)
411 .Annotation("Sqlite:Autoincrement", true),
412 AlphaIsActive = table.Column<bool>(nullable: false),
413 InstanceId = table.Column<long>(nullable: false),
414 AlphaId = table.Column<long>(nullable: true),
415 BravoId = table.Column<long>(nullable: true),
416 },
417 constraints: table =>
418 {
419 table.PrimaryKey("PK_WatchdogReattachInformations", x => x.Id);
420 table.ForeignKey(
421 name: "FK_WatchdogReattachInformations_ReattachInformations_AlphaId",
422 column: x => x.AlphaId,
423 principalTable: "ReattachInformations",
424 principalColumn: "Id",
425 onDelete: ReferentialAction.Restrict);
426 table.ForeignKey(
427 name: "FK_WatchdogReattachInformations_ReattachInformations_BravoId",
428 column: x => x.BravoId,
429 principalTable: "ReattachInformations",
430 principalColumn: "Id",
431 onDelete: ReferentialAction.Restrict);
432 table.ForeignKey(
433 name: "FK_WatchdogReattachInformations_Instances_InstanceId",
434 column: x => x.InstanceId,
435 principalTable: "Instances",
436 principalColumn: "Id",
437 onDelete: ReferentialAction.Cascade);
438 });
439
440 migrationBuilder.CreateIndex(
441 name: "IX_ChatBots_InstanceId_Name",
442 table: "ChatBots",
443 columns: new[] { "InstanceId", "Name" },
444 unique: true);
445
446 migrationBuilder.CreateIndex(
447 name: "IX_ChatChannels_ChatSettingsId_DiscordChannelId",
448 table: "ChatChannels",
449 columns: new[] { "ChatSettingsId", "DiscordChannelId" },
450 unique: true);
451
452 migrationBuilder.CreateIndex(
453 name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
454 table: "ChatChannels",
455 columns: new[] { "ChatSettingsId", "IrcChannel" },
456 unique: true);
457
458 migrationBuilder.CreateIndex(
459 name: "IX_CompileJobs_DirectoryName",
460 table: "CompileJobs",
461 column: "DirectoryName");
462
463 migrationBuilder.CreateIndex(
464 name: "IX_CompileJobs_JobId",
465 table: "CompileJobs",
466 column: "JobId",
467 unique: true);
468
469 migrationBuilder.CreateIndex(
470 name: "IX_CompileJobs_RevisionInformationId",
471 table: "CompileJobs",
472 column: "RevisionInformationId");
473
474 migrationBuilder.CreateIndex(
475 name: "IX_DreamDaemonSettings_InstanceId",
476 table: "DreamDaemonSettings",
477 column: "InstanceId",
478 unique: true);
479
480 migrationBuilder.CreateIndex(
481 name: "IX_DreamMakerSettings_InstanceId",
482 table: "DreamMakerSettings",
483 column: "InstanceId",
484 unique: true);
485
486 migrationBuilder.CreateIndex(
487 name: "IX_Instances_Path",
488 table: "Instances",
489 column: "Path",
490 unique: true);
491
492 migrationBuilder.CreateIndex(
493 name: "IX_InstanceUsers_InstanceId",
494 table: "InstanceUsers",
495 column: "InstanceId");
496
497 migrationBuilder.CreateIndex(
498 name: "IX_InstanceUsers_UserId_InstanceId",
499 table: "InstanceUsers",
500 columns: new[] { "UserId", "InstanceId" },
501 unique: true);
502
503 migrationBuilder.CreateIndex(
504 name: "IX_Jobs_CancelledById",
505 table: "Jobs",
506 column: "CancelledById");
507
508 migrationBuilder.CreateIndex(
509 name: "IX_Jobs_InstanceId",
510 table: "Jobs",
511 column: "InstanceId");
512
513 migrationBuilder.CreateIndex(
514 name: "IX_Jobs_StartedById",
515 table: "Jobs",
516 column: "StartedById");
517
518 migrationBuilder.CreateIndex(
519 name: "IX_ReattachInformations_CompileJobId",
520 table: "ReattachInformations",
521 column: "CompileJobId");
522
523 migrationBuilder.CreateIndex(
524 name: "IX_RepositorySettings_InstanceId",
525 table: "RepositorySettings",
526 column: "InstanceId",
527 unique: true);
528
529 migrationBuilder.CreateIndex(
530 name: "IX_RevInfoTestMerges_RevisionInformationId",
531 table: "RevInfoTestMerges",
532 column: "RevisionInformationId");
533
534 migrationBuilder.CreateIndex(
535 name: "IX_RevInfoTestMerges_TestMergeId",
536 table: "RevInfoTestMerges",
537 column: "TestMergeId");
538
539 migrationBuilder.CreateIndex(
540 name: "IX_RevisionInformations_InstanceId_CommitSha",
541 table: "RevisionInformations",
542 columns: new[] { "InstanceId", "CommitSha" },
543 unique: true);
544
545 migrationBuilder.CreateIndex(
546 name: "IX_TestMerges_MergedById",
547 table: "TestMerges",
548 column: "MergedById");
549
550 migrationBuilder.CreateIndex(
551 name: "IX_TestMerges_PrimaryRevisionInformationId",
552 table: "TestMerges",
553 column: "PrimaryRevisionInformationId",
554 unique: true);
555
556 migrationBuilder.CreateIndex(
557 name: "IX_Users_CanonicalName",
558 table: "Users",
559 column: "CanonicalName",
560 unique: true);
561
562 migrationBuilder.CreateIndex(
563 name: "IX_Users_CreatedById",
564 table: "Users",
565 column: "CreatedById");
566
567 migrationBuilder.CreateIndex(
568 name: "IX_Users_SystemIdentifier",
569 table: "Users",
570 column: "SystemIdentifier",
571 unique: true);
572
573 migrationBuilder.CreateIndex(
574 name: "IX_WatchdogReattachInformations_AlphaId",
575 table: "WatchdogReattachInformations",
576 column: "AlphaId");
577
578 migrationBuilder.CreateIndex(
579 name: "IX_WatchdogReattachInformations_BravoId",
580 table: "WatchdogReattachInformations",
581 column: "BravoId");
582
583 migrationBuilder.CreateIndex(
584 name: "IX_WatchdogReattachInformations_InstanceId",
585 table: "WatchdogReattachInformations",
586 column: "InstanceId",
587 unique: true);
588 }
589
591 protected override void Down(MigrationBuilder migrationBuilder)
592 {
593 ArgumentNullException.ThrowIfNull(migrationBuilder);
594
595 migrationBuilder.DropTable(
596 name: "ChatChannels");
597
598 migrationBuilder.DropTable(
599 name: "DreamDaemonSettings");
600
601 migrationBuilder.DropTable(
602 name: "DreamMakerSettings");
603
604 migrationBuilder.DropTable(
605 name: "InstanceUsers");
606
607 migrationBuilder.DropTable(
608 name: "RepositorySettings");
609
610 migrationBuilder.DropTable(
611 name: "RevInfoTestMerges");
612
613 migrationBuilder.DropTable(
614 name: "WatchdogReattachInformations");
615
616 migrationBuilder.DropTable(
617 name: "ChatBots");
618
619 migrationBuilder.DropTable(
620 name: "TestMerges");
621
622 migrationBuilder.DropTable(
623 name: "ReattachInformations");
624
625 migrationBuilder.DropTable(
626 name: "CompileJobs");
627
628 migrationBuilder.DropTable(
629 name: "Jobs");
630
631 migrationBuilder.DropTable(
632 name: "RevisionInformations");
633
634 migrationBuilder.DropTable(
635 name: "Users");
636
637 migrationBuilder.DropTable(
638 name: "Instances");
639 }
640 }
641}
override void Up(MigrationBuilder migrationBuilder)
override void Down(MigrationBuilder migrationBuilder)
@ Enabled
The OAuth Gateway is enabled.