tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
20180918204520_MYNullableAndForeignKeyCleanup.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_WatchdogReattachInfor~",
19 table: "Instances");
20
21 migrationBuilder.DropForeignKey(
22 name: "FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId",
23 table: "TestMerges");
24
25 migrationBuilder.DropForeignKey(
26 name: "FK_CompileJobs_Jobs_JobId",
27 table: "CompileJobs");
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_CompileJobs_JobId",
90 table: "CompileJobs",
91 column: "JobId",
92 unique: true);
93
94 migrationBuilder.AddForeignKey(
95 name: "FK_CompileJobs_Jobs_JobId",
96 table: "CompileJobs",
97 column: "JobId",
98 principalTable: "Jobs",
99 principalColumn: "Id",
100 onDelete: ReferentialAction.Restrict);
101
102 migrationBuilder.AddForeignKey(
103 name: "FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId",
104 table: "TestMerges",
105 column: "PrimaryRevisionInformationId",
106 principalTable: "RevisionInformations",
107 principalColumn: "Id",
108 onDelete: ReferentialAction.Restrict);
109
110 migrationBuilder.AddForeignKey(
111 name: "FK_WatchdogReattachInformations_Instances_InstanceId",
112 table: "WatchdogReattachInformations",
113 column: "InstanceId",
114 principalTable: "Instances",
115 principalColumn: "Id",
116 onDelete: ReferentialAction.Cascade);
117 }
118
120 protected override void Down(MigrationBuilder migrationBuilder)
121 {
122 ArgumentNullException.ThrowIfNull(migrationBuilder);
123
124 migrationBuilder.DropForeignKey(
125 name: "FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId",
126 table: "TestMerges");
127
128 migrationBuilder.DropForeignKey(
129 name: "FK_WatchdogReattachInformations_Instances_InstanceId",
130 table: "WatchdogReattachInformations");
131
132 migrationBuilder.DropForeignKey(
133 name: "FK_CompileJobs_Jobs_JobId",
134 table: "CompileJobs");
135
136 migrationBuilder.DropIndex(
137 name: "IX_WatchdogReattachInformations_InstanceId",
138 table: "WatchdogReattachInformations");
139
140 migrationBuilder.DropIndex(
141 name: "IX_CompileJobs_JobId",
142 table: "CompileJobs");
143
144 migrationBuilder.DropColumn(
145 name: "InstanceId",
146 table: "WatchdogReattachInformations");
147
148 migrationBuilder.AlterColumn<long>(
149 name: "PrimaryRevisionInformationId",
150 table: "TestMerges",
151 nullable: true,
152 oldClrType: typeof(long));
153
154 migrationBuilder.AddColumn<long>(
155 name: "WatchdogReattachInformationId",
156 table: "Instances",
157 nullable: true);
158
159 migrationBuilder.AlterColumn<string>(
160 name: "Output",
161 table: "CompileJobs",
162 nullable: true,
163 oldClrType: typeof(string));
164
165 migrationBuilder.AlterColumn<long>(
166 name: "JobId",
167 table: "CompileJobs",
168 nullable: true,
169 oldClrType: typeof(long));
170
171 migrationBuilder.AlterColumn<string>(
172 name: "DmeName",
173 table: "CompileJobs",
174 nullable: true,
175 oldClrType: typeof(string));
176
177 migrationBuilder.AlterColumn<Guid>(
178 name: "DirectoryName",
179 table: "CompileJobs",
180 nullable: true,
181 oldClrType: typeof(Guid));
182
183 migrationBuilder.CreateIndex(
184 name: "IX_Instances_WatchdogReattachInformationId",
185 table: "Instances",
186 column: "WatchdogReattachInformationId");
187
188 migrationBuilder.CreateIndex(
189 name: "IX_CompileJobs_JobId",
190 table: "CompileJobs",
191 column: "JobId");
192
193 migrationBuilder.AddForeignKey(
194 name: "FK_CompileJobs_Jobs_JobId",
195 table: "CompileJobs",
196 column: "JobId",
197 principalTable: "Jobs",
198 principalColumn: "Id",
199 onDelete: ReferentialAction.Restrict);
200
201 migrationBuilder.AddForeignKey(
202 name: "FK_Instances_WatchdogReattachInformations_WatchdogReattachInfor~",
203 table: "Instances",
204 column: "WatchdogReattachInformationId",
205 principalTable: "WatchdogReattachInformations",
206 principalColumn: "Id",
207 onDelete: ReferentialAction.Restrict);
208
209 migrationBuilder.AddForeignKey(
210 name: "FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId",
211 table: "TestMerges",
212 column: "PrimaryRevisionInformationId",
213 principalTable: "RevisionInformations",
214 principalColumn: "Id",
215 onDelete: ReferentialAction.SetNull);
216 }
217 }
218}