tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
20200629185014_SLRemoveExperimentalWatchdog.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.DropTable(
18 name: "WatchdogReattachInformations");
19
20 migrationBuilder.RenameTable(
21 name: "ReattachInformations",
22 newName: "ReattachInformations_up");
23
24 migrationBuilder.CreateTable(
25 name: "ReattachInformations",
26 columns: table => new
27 {
28 Id = table.Column<long>(nullable: false)
29 .Annotation("Sqlite:Autoincrement", true),
30 AccessIdentifier = table.Column<string>(nullable: false),
31 ProcessId = table.Column<int>(nullable: false),
32 Port = table.Column<ushort>(nullable: false),
33 RebootState = table.Column<int>(nullable: false),
34 LaunchSecurityLevel = table.Column<int>(nullable: false),
35 CompileJobId = table.Column<long>(nullable: false),
36 },
37 constraints: table =>
38 {
39 table.PrimaryKey("PK_ReattachInformations", x => x.Id);
40 table.ForeignKey(
41 name: "FK_ReattachInformations_CompileJobs_CompileJobId",
42 column: x => x.CompileJobId,
43 principalTable: "CompileJobs",
44 principalColumn: "Id",
45 onDelete: ReferentialAction.Cascade);
46 });
47
48 migrationBuilder.Sql(
49 $"INSERT INTO ReattachInformations SELECT Id,AccessIdentifier,ProcessId,Port,RebootState,LaunchSecurityLevel,CompileJobId FROM ReattachInformations_up");
50
51 migrationBuilder.DropTable(
52 name: "ReattachInformations_up");
53
54 migrationBuilder.RenameTable(
55 name: "DreamDaemonSettings",
56 newName: "DreamDaemonSettings_up");
57
58 migrationBuilder.CreateTable(
59 name: "DreamDaemonSettings",
60 columns: table => new
61 {
62 Id = table.Column<long>(nullable: false)
63 .Annotation("Sqlite:Autoincrement", true),
64 AllowWebClient = table.Column<bool>(nullable: false),
65 SecurityLevel = table.Column<int>(nullable: false),
66 Port = table.Column<ushort>(nullable: false),
67 StartupTimeout = table.Column<uint>(nullable: false),
68 HeartbeatSeconds = table.Column<uint>(nullable: false),
69 AutoStart = table.Column<bool>(nullable: false),
70 InstanceId = table.Column<long>(nullable: false),
71 TopicRequestTimeout = table.Column<uint>(nullable: false),
72 },
73 constraints: table =>
74 {
75 table.PrimaryKey("PK_DreamDaemonSettings", x => x.Id);
76 table.ForeignKey(
77 name: "FK_DreamDaemonSettings_Instances_InstanceId",
78 column: x => x.InstanceId,
79 principalTable: "Instances",
80 principalColumn: "Id",
81 onDelete: ReferentialAction.Cascade);
82 });
83
84 migrationBuilder.Sql(
85 $"INSERT INTO DreamDaemonSettings SELECT Id,AllowWebClient,SecurityLevel,PrimaryPort,AutoStart,HeartbeatSeconds,StartupTimeout,InstanceId,TopicRequestTimeout FROM DreamDaemonSettings_up");
86
87 migrationBuilder.DropTable(
88 name: "DreamDaemonSettings_up");
89 }
90
92 protected override void Down(MigrationBuilder migrationBuilder)
93 {
94 ArgumentNullException.ThrowIfNull(migrationBuilder);
95
96 migrationBuilder.RenameColumn(
97 name: "Port",
98 table: "DreamDaemonSettings",
99 newName: "PrimaryPort");
100
101 migrationBuilder.AddColumn<ushort>(
102 name: "SecondaryPort",
103 table: "DreamDaemonSettings",
104 type: "INTEGER",
105 nullable: false,
106 defaultValue: (ushort)0);
107
108 migrationBuilder.AddColumn<bool>(
109 name: "IsPrimary",
110 table: "ReattachInformations",
111 type: "INTEGER",
112 nullable: false,
113 defaultValue: false);
114
115 migrationBuilder.CreateTable(
116 name: "WatchdogReattachInformations",
117 columns: table => new
118 {
119 Id = table.Column<long>(type: "INTEGER", nullable: false)
120 .Annotation("Sqlite:Autoincrement", true),
121 AlphaId = table.Column<long>(type: "INTEGER", nullable: true),
122 AlphaIsActive = table.Column<bool>(type: "INTEGER", nullable: false),
123 BravoId = table.Column<long>(type: "INTEGER", nullable: true),
124 InstanceId = table.Column<long>(type: "INTEGER", nullable: false),
125 },
126 constraints: table =>
127 {
128 table.PrimaryKey("PK_WatchdogReattachInformations", x => x.Id);
129 table.ForeignKey(
130 name: "FK_WatchdogReattachInformations_ReattachInformations_AlphaId",
131 column: x => x.AlphaId,
132 principalTable: "ReattachInformations",
133 principalColumn: "Id",
134 onDelete: ReferentialAction.Restrict);
135 table.ForeignKey(
136 name: "FK_WatchdogReattachInformations_ReattachInformations_BravoId",
137 column: x => x.BravoId,
138 principalTable: "ReattachInformations",
139 principalColumn: "Id",
140 onDelete: ReferentialAction.Restrict);
141 table.ForeignKey(
142 name: "FK_WatchdogReattachInformations_Instances_InstanceId",
143 column: x => x.InstanceId,
144 principalTable: "Instances",
145 principalColumn: "Id",
146 onDelete: ReferentialAction.Cascade);
147 });
148
149 migrationBuilder.CreateIndex(
150 name: "IX_WatchdogReattachInformations_AlphaId",
151 table: "WatchdogReattachInformations",
152 column: "AlphaId");
153
154 migrationBuilder.CreateIndex(
155 name: "IX_WatchdogReattachInformations_BravoId",
156 table: "WatchdogReattachInformations",
157 column: "BravoId");
158
159 migrationBuilder.CreateIndex(
160 name: "IX_WatchdogReattachInformations_InstanceId",
161 table: "WatchdogReattachInformations",
162 column: "InstanceId",
163 unique: true);
164 }
165 }
166}
Removes the WatchdogReattachInformations table, SecondaryPort column, and renames the primary port co...