tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
20200705163700_SLAllowNullDMApi.cs
Go to the documentation of this file.
1using System;
2
3using Microsoft.EntityFrameworkCore.Migrations;
4
6
8{
12 public partial class SLAllowNullDMApi : Migration
13 {
15 protected override void Up(MigrationBuilder migrationBuilder)
16 {
17 ArgumentNullException.ThrowIfNull(migrationBuilder);
18
19 migrationBuilder.AddColumn<bool>(
20 name: "RequireDMApiValidation",
21 table: "DreamMakerSettings",
22 nullable: false,
23 defaultValue: true);
24
25 migrationBuilder.RenameTable(
26 name: "CompileJobs",
27 newName: "CompileJobs_up");
28
29 migrationBuilder.CreateTable(
30 name: "CompileJobs",
31 columns: table => new
32 {
33 Id = table.Column<long>(nullable: false)
34 .Annotation("Sqlite:Autoincrement", true),
35 DmeName = table.Column<string>(nullable: false),
36 Output = table.Column<string>(nullable: false),
37 DirectoryName = table.Column<Guid>(nullable: false),
38 MinimumSecurityLevel = table.Column<int>(nullable: true),
39 JobId = table.Column<long>(nullable: false),
40 RevisionInformationId = table.Column<long>(nullable: false),
41 ByondVersion = table.Column<string>(nullable: false),
42 DMApiMajorVersion = table.Column<int>(nullable: true),
43 DMApiMinorVersion = table.Column<int>(nullable: true),
44 DMApiPatchVersion = table.Column<int>(nullable: true),
45 },
46 constraints: table =>
47 {
48 table.PrimaryKey("PK_CompileJobs", x => x.Id);
49 table.ForeignKey(
50 name: "FK_CompileJobs_Jobs_JobId",
51 column: x => x.JobId,
52 principalTable: "Jobs",
53 principalColumn: "Id",
54 onDelete: ReferentialAction.Cascade);
55 table.ForeignKey(
56 name: "FK_CompileJobs_RevisionInformations_RevisionInformationId",
57 column: x => x.RevisionInformationId,
58 principalTable: "RevisionInformations",
59 principalColumn: "Id");
60 });
61
62 migrationBuilder.Sql(
63 $"INSERT INTO CompileJobs SELECT * FROM CompileJobs_up");
64
65 migrationBuilder.DropTable(
66 name: "CompileJobs_up");
67
68 // SQLite HATES this migration for some reason and thinks CompileJobs_up still exists???
69 migrationBuilder.RenameTable(
70 name: "CompileJobs",
71 newName: "CompileJobs_up");
72
73 migrationBuilder.RenameTable(
74 name: "CompileJobs_up",
75 newName: "CompileJobs");
76 }
77
79 protected override void Down(MigrationBuilder migrationBuilder)
80 {
81 ArgumentNullException.ThrowIfNull(migrationBuilder);
82
83 migrationBuilder.RenameTable(
84 name: "CompileJobs",
85 newName: "CompileJobs_down");
86
87 migrationBuilder.CreateTable(
88 name: "CompileJobs",
89 columns: table => new
90 {
91 Id = table.Column<long>(nullable: false)
92 .Annotation("Sqlite:Autoincrement", true),
93 DmeName = table.Column<string>(nullable: false),
94 Output = table.Column<string>(nullable: false),
95 DirectoryName = table.Column<Guid>(nullable: false),
96 MinimumSecurityLevel = table.Column<int>(nullable: false, defaultValue: DreamDaemonSecurity.Ultrasafe),
97 JobId = table.Column<long>(nullable: false),
98 RevisionInformationId = table.Column<long>(nullable: false),
99 ByondVersion = table.Column<string>(nullable: false),
100 DMApiMajorVersion = table.Column<int>(nullable: true),
101 DMApiMinorVersion = table.Column<int>(nullable: true),
102 DMApiPatchVersion = table.Column<int>(nullable: true),
103 },
104 constraints: table =>
105 {
106 table.PrimaryKey("PK_CompileJobs", x => x.Id);
107 table.ForeignKey(
108 name: "FK_CompileJobs_Jobs_JobId",
109 column: x => x.JobId,
110 principalTable: "Jobs",
111 principalColumn: "Id",
112 onDelete: ReferentialAction.Cascade);
113 table.ForeignKey(
114 name: "FK_CompileJobs_RevisionInformations_RevisionInformationId",
115 column: x => x.RevisionInformationId,
116 principalTable: "RevisionInformations",
117 principalColumn: "Id");
118 });
119
120 migrationBuilder.Sql(
121 $"INSERT INTO CompileJobs SELECT * FROM CompileJobs_down");
122
123 migrationBuilder.DropTable(
124 name: "CompileJobs_down");
125
126 migrationBuilder.RenameTable(
127 name: "CompileJobs",
128 newName: "CompileJobs_down");
129
130 migrationBuilder.RenameTable(
131 name: "CompileJobs_down",
132 newName: "CompileJobs");
133
134 migrationBuilder.RenameTable(
135 name: "DreamMakerSettings",
136 newName: "DreamMakerSettings_down");
137
138 migrationBuilder.CreateTable(
139 name: "DreamMakerSettings",
140 columns: table => new
141 {
142 Id = table.Column<long>(nullable: false)
143 .Annotation("Sqlite:Autoincrement", true),
144 ProjectName = table.Column<string>(maxLength: 10000, nullable: true),
145 ApiValidationPort = table.Column<ushort>(nullable: false),
146 ApiValidationSecurityLevel = table.Column<int>(nullable: false),
147 InstanceId = table.Column<long>(nullable: false),
148 },
149 constraints: table =>
150 {
151 table.PrimaryKey("PK_DreamMakerSettings", x => x.Id);
152 table.ForeignKey(
153 name: "FK_DreamMakerSettings_Instances_InstanceId",
154 column: x => x.InstanceId,
155 principalTable: "Instances",
156 principalColumn: "Id",
157 onDelete: ReferentialAction.Cascade);
158 });
159
160 migrationBuilder.Sql(
161 $"INSERT INTO DreamMakerSettings SELECT Id,ProjectName,ApiValidationPort,ApiValidationSecurityLevel,InstanceId FROM DreamMakerSettings_down");
162
163 migrationBuilder.DropTable(
164 name: "DreamMakerSettings_down");
165 }
166 }
167}
Update models for making the DMAPI optional for SQLite.
DreamDaemonSecurity
DreamDaemon's security level.