tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
20180918205224_MSNullableAndForeignKeyCleanup.cs
Go to the documentation of this file.
1using System;
2
3using Microsoft.EntityFrameworkCore.Migrations;
4
6{
11 {
13 protected override void Up(MigrationBuilder migrationBuilder)
14 {
15 ArgumentNullException.ThrowIfNull(migrationBuilder);
16
17 migrationBuilder.DropForeignKey(
18 name: "FK_Instances_WatchdogReattachInformations_WatchdogReattachInformationId",
19 table: "Instances");
20
21 migrationBuilder.DropForeignKey(
22 name: "FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId",
23 table: "TestMerges");
24
25 migrationBuilder.DropIndex(
26 name: "IX_TestMerges_PrimaryRevisionInformationId",
27 table: "TestMerges");
28
29 migrationBuilder.DropIndex(
30 name: "IX_Instances_WatchdogReattachInformationId",
31 table: "Instances");
32
33 migrationBuilder.DropIndex(
34 name: "IX_CompileJobs_JobId",
35 table: "CompileJobs");
36
37 migrationBuilder.DropColumn(
38 name: "WatchdogReattachInformationId",
39 table: "Instances");
40
41 migrationBuilder.AddColumn<long>(
42 name: "InstanceId",
43 table: "WatchdogReattachInformations",
44 nullable: false,
45 defaultValue: 0L);
46
47 migrationBuilder.AlterColumn<long>(
48 name: "PrimaryRevisionInformationId",
49 table: "TestMerges",
50 nullable: false,
51 oldClrType: typeof(long),
52 oldNullable: true);
53
54 migrationBuilder.AlterColumn<string>(
55 name: "Output",
56 table: "CompileJobs",
57 nullable: false,
58 oldClrType: typeof(string),
59 oldNullable: true);
60
61 migrationBuilder.AlterColumn<long>(
62 name: "JobId",
63 table: "CompileJobs",
64 nullable: false,
65 oldClrType: typeof(long),
66 oldNullable: true);
67
68 migrationBuilder.AlterColumn<string>(
69 name: "DmeName",
70 table: "CompileJobs",
71 nullable: false,
72 oldClrType: typeof(string),
73 oldNullable: true);
74
75 migrationBuilder.AlterColumn<Guid>(
76 name: "DirectoryName",
77 table: "CompileJobs",
78 nullable: false,
79 oldClrType: typeof(Guid),
80 oldNullable: true);
81
82 migrationBuilder.CreateIndex(
83 name: "IX_WatchdogReattachInformations_InstanceId",
84 table: "WatchdogReattachInformations",
85 column: "InstanceId",
86 unique: true);
87
88 migrationBuilder.CreateIndex(
89 name: "IX_TestMerges_PrimaryRevisionInformationId",
90 table: "TestMerges",
91 column: "PrimaryRevisionInformationId",
92 unique: true);
93
94 migrationBuilder.CreateIndex(
95 name: "IX_CompileJobs_JobId",
96 table: "CompileJobs",
97 column: "JobId",
98 unique: true);
99
100 migrationBuilder.AddForeignKey(
101 name: "FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId",
102 table: "TestMerges",
103 column: "PrimaryRevisionInformationId",
104 principalTable: "RevisionInformations",
105 principalColumn: "Id",
106 onDelete: ReferentialAction.Restrict);
107
108 migrationBuilder.AddForeignKey(
109 name: "FK_WatchdogReattachInformations_Instances_InstanceId",
110 table: "WatchdogReattachInformations",
111 column: "InstanceId",
112 principalTable: "Instances",
113 principalColumn: "Id",
114 onDelete: ReferentialAction.Cascade);
115 }
116
118 protected override void Down(MigrationBuilder migrationBuilder)
119 {
120 ArgumentNullException.ThrowIfNull(migrationBuilder);
121
122 migrationBuilder.DropForeignKey(
123 name: "FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId",
124 table: "TestMerges");
125
126 migrationBuilder.DropForeignKey(
127 name: "FK_WatchdogReattachInformations_Instances_InstanceId",
128 table: "WatchdogReattachInformations");
129
130 migrationBuilder.DropIndex(
131 name: "IX_WatchdogReattachInformations_InstanceId",
132 table: "WatchdogReattachInformations");
133
134 migrationBuilder.DropIndex(
135 name: "IX_TestMerges_PrimaryRevisionInformationId",
136 table: "TestMerges");
137
138 migrationBuilder.DropIndex(
139 name: "IX_CompileJobs_JobId",
140 table: "CompileJobs");
141
142 migrationBuilder.DropColumn(
143 name: "InstanceId",
144 table: "WatchdogReattachInformations");
145
146 migrationBuilder.AlterColumn<long>(
147 name: "PrimaryRevisionInformationId",
148 table: "TestMerges",
149 nullable: true,
150 oldClrType: typeof(long));
151
152 migrationBuilder.AddColumn<long>(
153 name: "WatchdogReattachInformationId",
154 table: "Instances",
155 nullable: true);
156
157 migrationBuilder.AlterColumn<string>(
158 name: "Output",
159 table: "CompileJobs",
160 nullable: true,
161 oldClrType: typeof(string));
162
163 migrationBuilder.AlterColumn<long>(
164 name: "JobId",
165 table: "CompileJobs",
166 nullable: true,
167 oldClrType: typeof(long));
168
169 migrationBuilder.AlterColumn<string>(
170 name: "DmeName",
171 table: "CompileJobs",
172 nullable: true,
173 oldClrType: typeof(string));
174
175 migrationBuilder.AlterColumn<Guid>(
176 name: "DirectoryName",
177 table: "CompileJobs",
178 nullable: true,
179 oldClrType: typeof(Guid));
180
181 migrationBuilder.CreateIndex(
182 name: "IX_TestMerges_PrimaryRevisionInformationId",
183 table: "TestMerges",
184 column: "PrimaryRevisionInformationId",
185 unique: true,
186 filter: "[PrimaryRevisionInformationId] IS NOT NULL");
187
188 migrationBuilder.CreateIndex(
189 name: "IX_Instances_WatchdogReattachInformationId",
190 table: "Instances",
191 column: "WatchdogReattachInformationId");
192
193 migrationBuilder.CreateIndex(
194 name: "IX_CompileJobs_JobId",
195 table: "CompileJobs",
196 column: "JobId");
197
198 migrationBuilder.AddForeignKey(
199 name: "FK_Instances_WatchdogReattachInformations_WatchdogReattachInformationId",
200 table: "Instances",
201 column: "WatchdogReattachInformationId",
202 principalTable: "WatchdogReattachInformations",
203 principalColumn: "Id",
204 onDelete: ReferentialAction.Restrict);
205
206 migrationBuilder.AddForeignKey(
207 name: "FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId",
208 table: "TestMerges",
209 column: "PrimaryRevisionInformationId",
210 principalTable: "RevisionInformations",
211 principalColumn: "Id",
212 onDelete: ReferentialAction.SetNull);
213 }
214 }
215}