tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
20200411170010_MYTonsOfValidation.cs
Go to the documentation of this file.
1using System;
2
3using Microsoft.EntityFrameworkCore.Migrations;
4
6{
10 public partial class MYTonsOfValidation : 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
75 migrationBuilder.CreateIndex(
76 name: "IX_ChatBots_InstanceId_Name",
77 table: "ChatBots",
78 columns: new[] { "InstanceId", "Name" },
79 unique: true);
80
81 migrationBuilder.CreateIndex(
82 name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
83 table: "ChatChannels",
84 columns: new[] { "ChatSettingsId", "IrcChannel" },
85 unique: true,
86 filter: "[IrcChannel] IS NOT NULL");
87
88 migrationBuilder.AddForeignKey(
89 name: "FK_ChatBots_Instances_InstanceId",
90 table: "ChatBots",
91 column: "InstanceId",
92 principalTable: "Instances",
93 principalColumn: "Id",
94 onDelete: ReferentialAction.Cascade);
95 }
96
98 protected override void Down(MigrationBuilder migrationBuilder)
99 {
100 ArgumentNullException.ThrowIfNull(migrationBuilder);
101
102 migrationBuilder.DropForeignKey(
103 name: "FK_ChatBots_Instances_InstanceId",
104 table: "ChatBots");
105
106 migrationBuilder.DropIndex(
107 name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
108 table: "ChatChannels");
109
110 migrationBuilder.DropIndex(
111 name: "IX_Users_SystemIdentifier",
112 table: "Users");
113
114 migrationBuilder.DropIndex(
115 name: "IX_ChatBots_InstanceId_Name",
116 table: "ChatBots");
117
118 migrationBuilder.AlterColumn<string>(
119 name: "SystemIdentifier",
120 table: "Users",
121 nullable: true,
122 oldClrType: typeof(string),
123 oldNullable: true);
124
125 migrationBuilder.AlterColumn<string>(
126 name: "PullRequestRevision",
127 table: "TestMerges",
128 nullable: false,
129 oldClrType: typeof(string),
130 oldMaxLength: 40);
131
132 migrationBuilder.AlterColumn<string>(
133 name: "IrcChannel",
134 table: "ChatChannels",
135 nullable: true,
136 oldClrType: typeof(string),
137 oldMaxLength: 100,
138 oldNullable: true);
139
140 migrationBuilder.AlterColumn<int>(
141 name: "Provider",
142 table: "ChatBots",
143 nullable: true,
144 oldClrType: typeof(int));
145
146 migrationBuilder.AlterColumn<string>(
147 name: "Name",
148 table: "ChatBots",
149 nullable: false,
150 oldClrType: typeof(string),
151 oldMaxLength: 100);
152
153 migrationBuilder.CreateIndex(
154 name: "IX_ChatBots_InstanceId",
155 table: "ChatBots",
156 column: "InstanceId");
157
158 migrationBuilder.CreateIndex(
159 name: "IX_ChatBots_Name",
160 table: "ChatBots",
161 column: "Name",
162 unique: true);
163
164 migrationBuilder.CreateIndex(
165 name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
166 table: "ChatChannels",
167 columns: new[] { "ChatSettingsId", "IrcChannel" },
168 unique: true,
169 filter: "[IrcChannel] IS NOT NULL");
170
171 migrationBuilder.AddForeignKey(
172 name: "FK_ChatBots_Instances_InstanceId",
173 table: "ChatBots",
174 column: "InstanceId",
175 principalTable: "Instances",
176 principalColumn: "Id",
177 onDelete: ReferentialAction.Cascade);
178 }
179 }
180}
Reduces column sizes and fixes some broken indexes for MYSQL.