tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
20200411164808_MSTonsOfValidation.cs
Go to the documentation of this file.
1using System;
2
3using Microsoft.EntityFrameworkCore.Migrations;
4
6{
10 public partial class MSTonsOfValidation : Migration
11 {
13 protected override void Up(MigrationBuilder migrationBuilder)
14 {
15 ArgumentNullException.ThrowIfNull(migrationBuilder);
16
17 migrationBuilder.DropForeignKey(
18 name: "FK_ChatBots_Instances_InstanceId",
19 table: "ChatBots");
20
21 migrationBuilder.DropIndex(
22 name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
23 table: "ChatChannels");
24
25 migrationBuilder.DropIndex(
26 name: "IX_ChatBots_InstanceId",
27 table: "ChatBots");
28
29 migrationBuilder.DropIndex(
30 name: "IX_ChatBots_Name",
31 table: "ChatBots");
32
33 migrationBuilder.AlterColumn<string>(
34 name: "SystemIdentifier",
35 table: "Users",
36 nullable: true,
37 oldClrType: typeof(string),
38 oldNullable: true);
39
40 migrationBuilder.AlterColumn<string>(
41 name: "PullRequestRevision",
42 table: "TestMerges",
43 maxLength: 40,
44 nullable: false,
45 oldClrType: typeof(string));
46
47 migrationBuilder.AlterColumn<string>(
48 name: "IrcChannel",
49 table: "ChatChannels",
50 maxLength: 100,
51 nullable: true,
52 oldClrType: typeof(string),
53 oldNullable: true);
54
55 migrationBuilder.AlterColumn<int>(
56 name: "Provider",
57 table: "ChatBots",
58 nullable: false,
59 oldClrType: typeof(int),
60 oldNullable: true);
61
62 migrationBuilder.AlterColumn<string>(
63 name: "Name",
64 table: "ChatBots",
65 maxLength: 100,
66 nullable: false,
67 oldClrType: typeof(string));
68
69 migrationBuilder.CreateIndex(
70 name: "IX_Users_SystemIdentifier",
71 table: "Users",
72 column: "SystemIdentifier",
73 unique: true,
74 filter: "[SystemIdentifier] IS NOT NULL");
75
76 migrationBuilder.CreateIndex(
77 name: "IX_ChatBots_InstanceId_Name",
78 table: "ChatBots",
79 columns: new[] { "InstanceId", "Name" },
80 unique: true);
81
82 migrationBuilder.CreateIndex(
83 name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
84 table: "ChatChannels",
85 columns: new[] { "ChatSettingsId", "IrcChannel" },
86 unique: true,
87 filter: "[IrcChannel] IS NOT NULL");
88
89 migrationBuilder.AddForeignKey(
90 name: "FK_ChatBots_Instances_InstanceId",
91 table: "ChatBots",
92 column: "InstanceId",
93 principalTable: "Instances",
94 principalColumn: "Id",
95 onDelete: ReferentialAction.Cascade);
96 }
97
99 protected override void Down(MigrationBuilder migrationBuilder)
100 {
101 ArgumentNullException.ThrowIfNull(migrationBuilder);
102
103 migrationBuilder.DropForeignKey(
104 name: "FK_ChatBots_Instances_InstanceId",
105 table: "ChatBots");
106
107 migrationBuilder.DropIndex(
108 name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
109 table: "ChatChannels");
110
111 migrationBuilder.DropIndex(
112 name: "IX_Users_SystemIdentifier",
113 table: "Users");
114
115 migrationBuilder.DropIndex(
116 name: "IX_ChatBots_InstanceId_Name",
117 table: "ChatBots");
118
119 migrationBuilder.AlterColumn<string>(
120 name: "SystemIdentifier",
121 table: "Users",
122 nullable: true,
123 oldClrType: typeof(string),
124 oldNullable: true);
125
126 migrationBuilder.AlterColumn<string>(
127 name: "PullRequestRevision",
128 table: "TestMerges",
129 nullable: false,
130 oldClrType: typeof(string),
131 oldMaxLength: 40);
132
133 migrationBuilder.AlterColumn<string>(
134 name: "IrcChannel",
135 table: "ChatChannels",
136 nullable: true,
137 oldClrType: typeof(string),
138 oldMaxLength: 100,
139 oldNullable: true);
140
141 migrationBuilder.AlterColumn<int>(
142 name: "Provider",
143 table: "ChatBots",
144 nullable: true,
145 oldClrType: typeof(int));
146
147 migrationBuilder.AlterColumn<string>(
148 name: "Name",
149 table: "ChatBots",
150 nullable: false,
151 oldClrType: typeof(string),
152 oldMaxLength: 100);
153
154 migrationBuilder.CreateIndex(
155 name: "IX_ChatBots_InstanceId",
156 table: "ChatBots",
157 column: "InstanceId");
158
159 migrationBuilder.CreateIndex(
160 name: "IX_ChatBots_Name",
161 table: "ChatBots",
162 column: "Name",
163 unique: true);
164
165 migrationBuilder.CreateIndex(
166 name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
167 table: "ChatChannels",
168 columns: new[] { "ChatSettingsId", "IrcChannel" },
169 unique: true,
170 filter: "[IrcChannel] IS NOT NULL");
171
172 migrationBuilder.AddForeignKey(
173 name: "FK_ChatBots_Instances_InstanceId",
174 table: "ChatBots",
175 column: "InstanceId",
176 principalTable: "Instances",
177 principalColumn: "Id",
178 onDelete: ReferentialAction.Cascade);
179 }
180 }
181}
Reduces column sizes and fixes some broken indexes for MSSQL.