diff --git a/src/Tgstation.Server.Host/Database/Migrations/20200807214754_SLAddDeploymentColumns.cs b/src/Tgstation.Server.Host/Database/Migrations/20200807214754_SLAddDeploymentColumns.cs index ea3e46b463..0635951093 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20200807214754_SLAddDeploymentColumns.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20200807214754_SLAddDeploymentColumns.cs @@ -37,17 +37,86 @@ namespace Tgstation.Server.Host.Database.Migrations if (migrationBuilder == null) throw new ArgumentNullException(nameof(migrationBuilder)); - migrationBuilder.DropColumn( - name: "CreateGitHubDeployments", - table: "RepositorySettings"); + migrationBuilder.RenameTable( + name: "RepositorySettings", + newName: "RepositorySettings_down"); - migrationBuilder.DropColumn( - name: "GitHubDeploymentId", - table: "CompileJobs"); + migrationBuilder.CreateTable( + name: "RepositorySettings", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + CommitterName = table.Column(maxLength: 10000, nullable: false), + CommitterEmail = table.Column(maxLength: 10000, nullable: false), + AccessUser = table.Column(maxLength: 10000, nullable: true), + AccessToken = table.Column(maxLength: 10000, nullable: true), + PushTestMergeCommits = table.Column(nullable: false), + ShowTestMergeCommitters = table.Column(nullable: false), + AutoUpdatesKeepTestMerges = table.Column(nullable: false), + AutoUpdatesSynchronize = table.Column(nullable: false), + PostTestMergeComment = table.Column(nullable: false), + InstanceId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RepositorySettings", x => x.Id); + table.ForeignKey( + name: "FK_RepositorySettings_Instances_InstanceId", + column: x => x.InstanceId, + principalTable: "Instances", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); - migrationBuilder.DropColumn( - name: "GitHubRepoId", - table: "CompileJobs"); + migrationBuilder.Sql( + $"INSERT INTO RepositorySettings SELECT Id,CommitterName,CommitterEmail,AccessUser,AccessToken,PushTestMergeCommits,ShowTestMergeCommitters,AutoUpdatesKeepTestMerges,AutoUpdatesSynchronize,PostTestMergeComment,InstanceId FROM RepositorySettings_down"); + + migrationBuilder.DropTable( + name: "RepositorySettings_down"); + + migrationBuilder.RenameTable( + name: "CompileJobs", + newName: "CompileJobs_down"); + + migrationBuilder.CreateTable( + name: "CompileJobs", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + DmeName = table.Column(nullable: false), + Output = table.Column(nullable: false), + DirectoryName = table.Column(nullable: false), + MinimumSecurityLevel = table.Column(nullable: true), + JobId = table.Column(nullable: false), + RevisionInformationId = table.Column(nullable: false), + ByondVersion = table.Column(nullable: false), + DMApiMajorVersion = table.Column(nullable: true), + DMApiMinorVersion = table.Column(nullable: true), + DMApiPatchVersion = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CompileJobs", x => x.Id); + table.ForeignKey( + name: "FK_CompileJobs_Jobs_JobId", + column: x => x.JobId, + principalTable: "Jobs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_CompileJobs_RevisionInformations_RevisionInformationId", + column: x => x.RevisionInformationId, + principalTable: "RevisionInformations", + principalColumn: "Id"); + }); + + migrationBuilder.Sql( + $"INSERT INTO CompileJobs SELECT Id,DmeName,Output,DirectoryName,MinimumSecurityLevel,JobId,RevisionInformationId,ByondVersion,DMApiMajorVersion,DMApiMinorVersion,DMApiPatchVersion FROM CompileJobs_down"); + + migrationBuilder.DropTable( + name: "CompileJobs_down"); } } }