using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Microsoft.SelfService.Portal.Core.API.Migrations { /// public partial class RenameDeploymentAndJobTables : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_DeploymentGroups_Templates_TemplateId", table: "DeploymentGroups"); migrationBuilder.DropForeignKey( name: "FK_Deployments_DeploymentGroups_DeploymentGroupId", table: "Deployments"); migrationBuilder.DropForeignKey( name: "FK_Deployments_VirtualMachines_VirtualMachineId", table: "Deployments"); migrationBuilder.DropForeignKey( name: "FK_Jobs_Deployments_DeploymentId", table: "Jobs"); migrationBuilder.DropForeignKey( name: "FK_QueueJobSteps_QueueJobSteps_DependsOnQueueJobStepId", table: "QueueJobSteps"); migrationBuilder.DropForeignKey( name: "FK_QueueJobSteps_QueueJobs_QueueJobId", table: "QueueJobSteps"); migrationBuilder.DropForeignKey( name: "FK_QueueJobTargets_QueueJobs_QueueJobId", table: "QueueJobTargets"); migrationBuilder.DropPrimaryKey( name: "PK_QueueJobTargets", table: "QueueJobTargets"); migrationBuilder.DropPrimaryKey( name: "PK_QueueJobSteps", table: "QueueJobSteps"); migrationBuilder.DropPrimaryKey( name: "PK_QueueJobs", table: "QueueJobs"); migrationBuilder.DropUniqueConstraint( name: "AK_Deployments_Id", table: "Deployments"); migrationBuilder.DropPrimaryKey( name: "PK_Deployments", table: "Deployments"); migrationBuilder.DropPrimaryKey( name: "PK_DeploymentGroups", table: "DeploymentGroups"); migrationBuilder.RenameTable( name: "QueueJobTargets", newName: "DeploymentJobTargets"); migrationBuilder.RenameTable( name: "QueueJobSteps", newName: "DeploymentJobSteps"); migrationBuilder.RenameTable( name: "QueueJobs", newName: "DeploymentJobs"); migrationBuilder.RenameTable( name: "Deployments", newName: "DeploymentExecutions"); migrationBuilder.RenameTable( name: "DeploymentGroups", newName: "DeploymentBatches"); migrationBuilder.RenameIndex( name: "IX_QueueJobTargets_QueueJobId", table: "DeploymentJobTargets", newName: "IX_DeploymentJobTargets_QueueJobId"); migrationBuilder.RenameIndex( name: "IX_QueueJobSteps_QueueJobId", table: "DeploymentJobSteps", newName: "IX_DeploymentJobSteps_QueueJobId"); migrationBuilder.RenameIndex( name: "IX_QueueJobSteps_DependsOnQueueJobStepId", table: "DeploymentJobSteps", newName: "IX_DeploymentJobSteps_DependsOnQueueJobStepId"); migrationBuilder.RenameIndex( name: "IX_Deployments_DeploymentGroupId", table: "DeploymentExecutions", newName: "IX_DeploymentExecutions_DeploymentGroupId"); migrationBuilder.RenameIndex( name: "IX_DeploymentGroups_TemplateId", table: "DeploymentBatches", newName: "IX_DeploymentBatches_TemplateId"); migrationBuilder.AddPrimaryKey( name: "PK_DeploymentJobTargets", table: "DeploymentJobTargets", column: "Id"); migrationBuilder.AddPrimaryKey( name: "PK_DeploymentJobSteps", table: "DeploymentJobSteps", column: "Id"); migrationBuilder.AddPrimaryKey( name: "PK_DeploymentJobs", table: "DeploymentJobs", column: "Id"); migrationBuilder.AddUniqueConstraint( name: "AK_DeploymentExecutions_Id", table: "DeploymentExecutions", column: "Id"); migrationBuilder.AddPrimaryKey( name: "PK_DeploymentExecutions", table: "DeploymentExecutions", columns: new[] { "VirtualMachineId", "DeploymentGroupId" }); migrationBuilder.AddPrimaryKey( name: "PK_DeploymentBatches", table: "DeploymentBatches", column: "Id"); migrationBuilder.AddForeignKey( name: "FK_DeploymentBatches_Templates_TemplateId", table: "DeploymentBatches", column: "TemplateId", principalTable: "Templates", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_DeploymentExecutions_DeploymentBatches_DeploymentGroupId", table: "DeploymentExecutions", column: "DeploymentGroupId", principalTable: "DeploymentBatches", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_DeploymentExecutions_VirtualMachines_VirtualMachineId", table: "DeploymentExecutions", column: "VirtualMachineId", principalTable: "VirtualMachines", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_DeploymentJobSteps_DeploymentJobSteps_DependsOnQueueJobStepId", table: "DeploymentJobSteps", column: "DependsOnQueueJobStepId", principalTable: "DeploymentJobSteps", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_DeploymentJobSteps_DeploymentJobs_QueueJobId", table: "DeploymentJobSteps", column: "QueueJobId", principalTable: "DeploymentJobs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_DeploymentJobTargets_DeploymentJobs_QueueJobId", table: "DeploymentJobTargets", column: "QueueJobId", principalTable: "DeploymentJobs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_Jobs_DeploymentExecutions_DeploymentId", table: "Jobs", column: "DeploymentId", principalTable: "DeploymentExecutions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_DeploymentBatches_Templates_TemplateId", table: "DeploymentBatches"); migrationBuilder.DropForeignKey( name: "FK_DeploymentExecutions_DeploymentBatches_DeploymentGroupId", table: "DeploymentExecutions"); migrationBuilder.DropForeignKey( name: "FK_DeploymentExecutions_VirtualMachines_VirtualMachineId", table: "DeploymentExecutions"); migrationBuilder.DropForeignKey( name: "FK_DeploymentJobSteps_DeploymentJobSteps_DependsOnQueueJobStepId", table: "DeploymentJobSteps"); migrationBuilder.DropForeignKey( name: "FK_DeploymentJobSteps_DeploymentJobs_QueueJobId", table: "DeploymentJobSteps"); migrationBuilder.DropForeignKey( name: "FK_DeploymentJobTargets_DeploymentJobs_QueueJobId", table: "DeploymentJobTargets"); migrationBuilder.DropForeignKey( name: "FK_Jobs_DeploymentExecutions_DeploymentId", table: "Jobs"); migrationBuilder.DropPrimaryKey( name: "PK_DeploymentJobTargets", table: "DeploymentJobTargets"); migrationBuilder.DropPrimaryKey( name: "PK_DeploymentJobSteps", table: "DeploymentJobSteps"); migrationBuilder.DropPrimaryKey( name: "PK_DeploymentJobs", table: "DeploymentJobs"); migrationBuilder.DropUniqueConstraint( name: "AK_DeploymentExecutions_Id", table: "DeploymentExecutions"); migrationBuilder.DropPrimaryKey( name: "PK_DeploymentExecutions", table: "DeploymentExecutions"); migrationBuilder.DropPrimaryKey( name: "PK_DeploymentBatches", table: "DeploymentBatches"); migrationBuilder.RenameTable( name: "DeploymentJobTargets", newName: "QueueJobTargets"); migrationBuilder.RenameTable( name: "DeploymentJobSteps", newName: "QueueJobSteps"); migrationBuilder.RenameTable( name: "DeploymentJobs", newName: "QueueJobs"); migrationBuilder.RenameTable( name: "DeploymentExecutions", newName: "Deployments"); migrationBuilder.RenameTable( name: "DeploymentBatches", newName: "DeploymentGroups"); migrationBuilder.RenameIndex( name: "IX_DeploymentJobTargets_QueueJobId", table: "QueueJobTargets", newName: "IX_QueueJobTargets_QueueJobId"); migrationBuilder.RenameIndex( name: "IX_DeploymentJobSteps_QueueJobId", table: "QueueJobSteps", newName: "IX_QueueJobSteps_QueueJobId"); migrationBuilder.RenameIndex( name: "IX_DeploymentJobSteps_DependsOnQueueJobStepId", table: "QueueJobSteps", newName: "IX_QueueJobSteps_DependsOnQueueJobStepId"); migrationBuilder.RenameIndex( name: "IX_DeploymentExecutions_DeploymentGroupId", table: "Deployments", newName: "IX_Deployments_DeploymentGroupId"); migrationBuilder.RenameIndex( name: "IX_DeploymentBatches_TemplateId", table: "DeploymentGroups", newName: "IX_DeploymentGroups_TemplateId"); migrationBuilder.AddPrimaryKey( name: "PK_QueueJobTargets", table: "QueueJobTargets", column: "Id"); migrationBuilder.AddPrimaryKey( name: "PK_QueueJobSteps", table: "QueueJobSteps", column: "Id"); migrationBuilder.AddPrimaryKey( name: "PK_QueueJobs", table: "QueueJobs", column: "Id"); migrationBuilder.AddUniqueConstraint( name: "AK_Deployments_Id", table: "Deployments", column: "Id"); migrationBuilder.AddPrimaryKey( name: "PK_Deployments", table: "Deployments", columns: new[] { "VirtualMachineId", "DeploymentGroupId" }); migrationBuilder.AddPrimaryKey( name: "PK_DeploymentGroups", table: "DeploymentGroups", column: "Id"); migrationBuilder.AddForeignKey( name: "FK_DeploymentGroups_Templates_TemplateId", table: "DeploymentGroups", column: "TemplateId", principalTable: "Templates", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_Deployments_DeploymentGroups_DeploymentGroupId", table: "Deployments", column: "DeploymentGroupId", principalTable: "DeploymentGroups", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_Deployments_VirtualMachines_VirtualMachineId", table: "Deployments", column: "VirtualMachineId", principalTable: "VirtualMachines", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_Jobs_Deployments_DeploymentId", table: "Jobs", column: "DeploymentId", principalTable: "Deployments", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_QueueJobSteps_QueueJobSteps_DependsOnQueueJobStepId", table: "QueueJobSteps", column: "DependsOnQueueJobStepId", principalTable: "QueueJobSteps", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_QueueJobSteps_QueueJobs_QueueJobId", table: "QueueJobSteps", column: "QueueJobId", principalTable: "QueueJobs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_QueueJobTargets_QueueJobs_QueueJobId", table: "QueueJobTargets", column: "QueueJobId", principalTable: "QueueJobs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } } }