From 4dcd5da7f49d8e4783f1f1a2821d187378c9ef7f Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 11 Aug 2022 17:21:19 -0400 Subject: [PATCH] "Fix" SQLite down migration --- ...20811163432_SLAddDumpOnHeartbeatRestart.cs | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/Migrations/20220811163432_SLAddDumpOnHeartbeatRestart.cs b/src/Tgstation.Server.Host/Database/Migrations/20220811163432_SLAddDumpOnHeartbeatRestart.cs index aa3381df73..c377674b97 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20220811163432_SLAddDumpOnHeartbeatRestart.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20220811163432_SLAddDumpOnHeartbeatRestart.cs @@ -28,9 +28,51 @@ namespace Tgstation.Server.Host.Database.Migrations if (migrationBuilder == null) throw new ArgumentNullException(nameof(migrationBuilder)); - migrationBuilder.DropColumn( - name: "DumpOnHeartbeatRestart", - table: "DreamDaemonSettings"); + migrationBuilder.RenameTable( + name: "DreamDaemonSettings", + newName: "DreamDaemonSettings_down"); + + migrationBuilder.CreateTable( + name: "DreamDaemonSettings", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + AllowWebClient = table.Column(nullable: false), + SecurityLevel = table.Column(nullable: false), + Port = table.Column(nullable: false), + StartupTimeout = table.Column(nullable: false), + HeartbeatSeconds = table.Column(nullable: false), + AutoStart = table.Column(nullable: false), + InstanceId = table.Column(nullable: false), + TopicRequestTimeout = table.Column(nullable: false), + AdditionalParameters = table.Column(maxLength: 10000, nullable: false), + Visibility = table.Column(nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_DreamDaemonSettings", x => x.Id); + table.ForeignKey( + name: "FK_DreamDaemonSettings_Instances_InstanceId", + column: x => x.InstanceId, + principalTable: "Instances", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.Sql( + $"INSERT INTO DreamDaemonSettings SELECT Id,AllowWebClient,SecurityLevel,Port,AutoStart,HeartbeatSeconds,StartupTimeout,InstanceId,TopicRequestTimeout,AdditionalParameters,Visibility FROM DreamDaemonSettings_down"); + + migrationBuilder.DropTable( + name: "DreamDaemonSettings_down"); + + migrationBuilder.RenameTable( + name: "DreamDaemonSettings", + newName: "DreamDaemonSettings_down"); + + migrationBuilder.RenameTable( + name: "DreamDaemonSettings_down", + newName: "DreamDaemonSettings"); } } }