15 protected override void Up(MigrationBuilder migrationBuilder)
17 ArgumentNullException.ThrowIfNull(migrationBuilder);
19 migrationBuilder.CreateTable(
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),
34 table.PrimaryKey(
"PK_Instances", x => x.Id);
37 migrationBuilder.CreateTable(
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),
56 table.PrimaryKey(
"PK_Users", x => x.Id);
58 name:
"FK_Users_Users_CreatedById",
59 column: x => x.CreatedById,
60 principalTable:
"Users",
61 principalColumn:
"Id",
62 onDelete: ReferentialAction.Restrict);
65 migrationBuilder.CreateTable(
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),
81 table.PrimaryKey(
"PK_ChatBots", x => x.Id);
83 name:
"FK_ChatBots_Instances_InstanceId",
84 column: x => x.InstanceId,
85 principalTable:
"Instances",
86 principalColumn:
"Id",
87 onDelete: ReferentialAction.Cascade);
90 migrationBuilder.CreateTable(
91 name:
"DreamDaemonSettings",
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),
108 constraints: table =>
110 table.PrimaryKey(
"PK_DreamDaemonSettings", x => x.Id);
112 name:
"FK_DreamDaemonSettings_Instances_InstanceId",
113 column: x => x.InstanceId,
114 principalTable:
"Instances",
115 principalColumn:
"Id",
116 onDelete: ReferentialAction.Cascade);
119 migrationBuilder.CreateTable(
120 name:
"DreamMakerSettings",
121 columns: table =>
new
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),
130 constraints: table =>
132 table.PrimaryKey(
"PK_DreamMakerSettings", x => x.Id);
134 name:
"FK_DreamMakerSettings_Instances_InstanceId",
135 column: x => x.InstanceId,
136 principalTable:
"Instances",
137 principalColumn:
"Id",
138 onDelete: ReferentialAction.Cascade);
141 migrationBuilder.CreateTable(
142 name:
"RepositorySettings",
143 columns: table =>
new
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),
158 constraints: table =>
160 table.PrimaryKey(
"PK_RepositorySettings", x => x.Id);
162 name:
"FK_RepositorySettings_Instances_InstanceId",
163 column: x => x.InstanceId,
164 principalTable:
"Instances",
165 principalColumn:
"Id",
166 onDelete: ReferentialAction.Cascade);
169 migrationBuilder.CreateTable(
170 name:
"RevisionInformations",
171 columns: table =>
new
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),
179 constraints: table =>
181 table.PrimaryKey(
"PK_RevisionInformations", x => x.Id);
183 name:
"FK_RevisionInformations_Instances_InstanceId",
184 column: x => x.InstanceId,
185 principalTable:
"Instances",
186 principalColumn:
"Id",
187 onDelete: ReferentialAction.Cascade);
190 migrationBuilder.CreateTable(
191 name:
"InstanceUsers",
192 columns: table =>
new
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),
206 constraints: table =>
208 table.PrimaryKey(
"PK_InstanceUsers", x => x.Id);
210 name:
"FK_InstanceUsers_Instances_InstanceId",
211 column: x => x.InstanceId,
212 principalTable:
"Instances",
213 principalColumn:
"Id",
214 onDelete: ReferentialAction.Cascade);
216 name:
"FK_InstanceUsers_Users_UserId",
217 column: x => x.UserId,
218 principalTable:
"Users",
219 principalColumn:
"Id",
220 onDelete: ReferentialAction.Cascade);
223 migrationBuilder.CreateTable(
225 columns: table =>
new
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),
241 constraints: table =>
243 table.PrimaryKey(
"PK_Jobs", x => x.Id);
245 name:
"FK_Jobs_Users_CancelledById",
246 column: x => x.CancelledById,
247 principalTable:
"Users",
248 principalColumn:
"Id",
249 onDelete: ReferentialAction.Restrict);
251 name:
"FK_Jobs_Instances_InstanceId",
252 column: x => x.InstanceId,
253 principalTable:
"Instances",
254 principalColumn:
"Id",
255 onDelete: ReferentialAction.Cascade);
257 name:
"FK_Jobs_Users_StartedById",
258 column: x => x.StartedById,
259 principalTable:
"Users",
260 principalColumn:
"Id",
261 onDelete: ReferentialAction.Cascade);
264 migrationBuilder.CreateTable(
265 name:
"ChatChannels",
266 columns: table =>
new
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),
278 constraints: table =>
280 table.PrimaryKey(
"PK_ChatChannels", x => x.Id);
282 name:
"FK_ChatChannels_ChatBots_ChatSettingsId",
283 column: x => x.ChatSettingsId,
284 principalTable:
"ChatBots",
285 principalColumn:
"Id",
286 onDelete: ReferentialAction.Cascade);
289 migrationBuilder.CreateTable(
291 columns: table =>
new
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),
306 constraints: table =>
308 table.PrimaryKey(
"PK_TestMerges", x => x.Id);
310 name:
"FK_TestMerges_Users_MergedById",
311 column: x => x.MergedById,
312 principalTable:
"Users",
313 principalColumn:
"Id",
314 onDelete: ReferentialAction.Restrict);
316 name:
"FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId",
317 column: x => x.PrimaryRevisionInformationId,
318 principalTable:
"RevisionInformations",
319 principalColumn:
"Id",
320 onDelete: ReferentialAction.Cascade);
323 migrationBuilder.CreateTable(
325 columns: table =>
new
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),
340 constraints: table =>
342 table.PrimaryKey(
"PK_CompileJobs", x => x.Id);
344 name:
"FK_CompileJobs_Jobs_JobId",
345 column: x => x.JobId,
346 principalTable:
"Jobs",
347 principalColumn:
"Id",
348 onDelete: ReferentialAction.Cascade);
350 name:
"FK_CompileJobs_RevisionInformations_RevisionInformationId",
351 column: x => x.RevisionInformationId,
352 principalTable:
"RevisionInformations",
353 principalColumn:
"Id");
356 migrationBuilder.CreateTable(
357 name:
"RevInfoTestMerges",
358 columns: table =>
new
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),
365 constraints: table =>
367 table.PrimaryKey(
"PK_RevInfoTestMerges", x => x.Id);
369 name:
"FK_RevInfoTestMerges_RevisionInformations_RevisionInformationId",
370 column: x => x.RevisionInformationId,
371 principalTable:
"RevisionInformations",
372 principalColumn:
"Id",
373 onDelete: ReferentialAction.Cascade);
375 name:
"FK_RevInfoTestMerges_TestMerges_TestMergeId",
376 column: x => x.TestMergeId,
377 principalTable:
"TestMerges",
378 principalColumn:
"Id");
381 migrationBuilder.CreateTable(
382 name:
"ReattachInformations",
383 columns: table =>
new
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),
395 constraints: table =>
397 table.PrimaryKey(
"PK_ReattachInformations", x => x.Id);
399 name:
"FK_ReattachInformations_CompileJobs_CompileJobId",
400 column: x => x.CompileJobId,
401 principalTable:
"CompileJobs",
402 principalColumn:
"Id",
403 onDelete: ReferentialAction.Cascade);
406 migrationBuilder.CreateTable(
407 name:
"WatchdogReattachInformations",
408 columns: table =>
new
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),
417 constraints: table =>
419 table.PrimaryKey(
"PK_WatchdogReattachInformations", x => x.Id);
421 name:
"FK_WatchdogReattachInformations_ReattachInformations_AlphaId",
422 column: x => x.AlphaId,
423 principalTable:
"ReattachInformations",
424 principalColumn:
"Id",
425 onDelete: ReferentialAction.Restrict);
427 name:
"FK_WatchdogReattachInformations_ReattachInformations_BravoId",
428 column: x => x.BravoId,
429 principalTable:
"ReattachInformations",
430 principalColumn:
"Id",
431 onDelete: ReferentialAction.Restrict);
433 name:
"FK_WatchdogReattachInformations_Instances_InstanceId",
434 column: x => x.InstanceId,
435 principalTable:
"Instances",
436 principalColumn:
"Id",
437 onDelete: ReferentialAction.Cascade);
440 migrationBuilder.CreateIndex(
441 name:
"IX_ChatBots_InstanceId_Name",
443 columns:
new[] {
"InstanceId",
"Name" },
446 migrationBuilder.CreateIndex(
447 name:
"IX_ChatChannels_ChatSettingsId_DiscordChannelId",
448 table:
"ChatChannels",
449 columns:
new[] {
"ChatSettingsId",
"DiscordChannelId" },
452 migrationBuilder.CreateIndex(
453 name:
"IX_ChatChannels_ChatSettingsId_IrcChannel",
454 table:
"ChatChannels",
455 columns:
new[] {
"ChatSettingsId",
"IrcChannel" },
458 migrationBuilder.CreateIndex(
459 name:
"IX_CompileJobs_DirectoryName",
460 table:
"CompileJobs",
461 column:
"DirectoryName");
463 migrationBuilder.CreateIndex(
464 name:
"IX_CompileJobs_JobId",
465 table:
"CompileJobs",
469 migrationBuilder.CreateIndex(
470 name:
"IX_CompileJobs_RevisionInformationId",
471 table:
"CompileJobs",
472 column:
"RevisionInformationId");
474 migrationBuilder.CreateIndex(
475 name:
"IX_DreamDaemonSettings_InstanceId",
476 table:
"DreamDaemonSettings",
477 column:
"InstanceId",
480 migrationBuilder.CreateIndex(
481 name:
"IX_DreamMakerSettings_InstanceId",
482 table:
"DreamMakerSettings",
483 column:
"InstanceId",
486 migrationBuilder.CreateIndex(
487 name:
"IX_Instances_Path",
492 migrationBuilder.CreateIndex(
493 name:
"IX_InstanceUsers_InstanceId",
494 table:
"InstanceUsers",
495 column:
"InstanceId");
497 migrationBuilder.CreateIndex(
498 name:
"IX_InstanceUsers_UserId_InstanceId",
499 table:
"InstanceUsers",
500 columns:
new[] {
"UserId",
"InstanceId" },
503 migrationBuilder.CreateIndex(
504 name:
"IX_Jobs_CancelledById",
506 column:
"CancelledById");
508 migrationBuilder.CreateIndex(
509 name:
"IX_Jobs_InstanceId",
511 column:
"InstanceId");
513 migrationBuilder.CreateIndex(
514 name:
"IX_Jobs_StartedById",
516 column:
"StartedById");
518 migrationBuilder.CreateIndex(
519 name:
"IX_ReattachInformations_CompileJobId",
520 table:
"ReattachInformations",
521 column:
"CompileJobId");
523 migrationBuilder.CreateIndex(
524 name:
"IX_RepositorySettings_InstanceId",
525 table:
"RepositorySettings",
526 column:
"InstanceId",
529 migrationBuilder.CreateIndex(
530 name:
"IX_RevInfoTestMerges_RevisionInformationId",
531 table:
"RevInfoTestMerges",
532 column:
"RevisionInformationId");
534 migrationBuilder.CreateIndex(
535 name:
"IX_RevInfoTestMerges_TestMergeId",
536 table:
"RevInfoTestMerges",
537 column:
"TestMergeId");
539 migrationBuilder.CreateIndex(
540 name:
"IX_RevisionInformations_InstanceId_CommitSha",
541 table:
"RevisionInformations",
542 columns:
new[] {
"InstanceId",
"CommitSha" },
545 migrationBuilder.CreateIndex(
546 name:
"IX_TestMerges_MergedById",
548 column:
"MergedById");
550 migrationBuilder.CreateIndex(
551 name:
"IX_TestMerges_PrimaryRevisionInformationId",
553 column:
"PrimaryRevisionInformationId",
556 migrationBuilder.CreateIndex(
557 name:
"IX_Users_CanonicalName",
559 column:
"CanonicalName",
562 migrationBuilder.CreateIndex(
563 name:
"IX_Users_CreatedById",
565 column:
"CreatedById");
567 migrationBuilder.CreateIndex(
568 name:
"IX_Users_SystemIdentifier",
570 column:
"SystemIdentifier",
573 migrationBuilder.CreateIndex(
574 name:
"IX_WatchdogReattachInformations_AlphaId",
575 table:
"WatchdogReattachInformations",
578 migrationBuilder.CreateIndex(
579 name:
"IX_WatchdogReattachInformations_BravoId",
580 table:
"WatchdogReattachInformations",
583 migrationBuilder.CreateIndex(
584 name:
"IX_WatchdogReattachInformations_InstanceId",
585 table:
"WatchdogReattachInformations",
586 column:
"InstanceId",