using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Microsoft.SelfService.Portal.Core.API.Migrations
{
///
public partial class AddQueueHardening : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_DeploymentJobTargets_DeploymentJobId",
table: "DeploymentJobTargets");
migrationBuilder.DropIndex(
name: "IX_DeploymentJobSteps_DeploymentJobId",
table: "DeploymentJobSteps");
migrationBuilder.AlterColumn(
name: "Status",
table: "DeploymentJobTargets",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AddColumn(
name: "Finished",
table: "DeploymentJobTargets",
type: "datetime2",
nullable: true)
.Annotation("Relational:ColumnOrder", 9);
migrationBuilder.AddColumn(
name: "OutputMetadataJson",
table: "DeploymentJobTargets",
type: "nvarchar(max)",
nullable: true)
.Annotation("Relational:ColumnOrder", 10);
migrationBuilder.AddColumn(
name: "Started",
table: "DeploymentJobTargets",
type: "datetime2",
nullable: true)
.Annotation("Relational:ColumnOrder", 8);
migrationBuilder.AlterColumn(
name: "Status",
table: "DeploymentJobSteps",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AddColumn(
name: "ErrorMessage",
table: "DeploymentJobSteps",
type: "nvarchar(max)",
nullable: true)
.Annotation("Relational:ColumnOrder", 14);
migrationBuilder.AddColumn(
name: "Finished",
table: "DeploymentJobSteps",
type: "datetime2",
nullable: true)
.Annotation("Relational:ColumnOrder", 12);
migrationBuilder.AddColumn(
name: "OutputMetadataJson",
table: "DeploymentJobSteps",
type: "nvarchar(max)",
nullable: true)
.Annotation("Relational:ColumnOrder", 13);
migrationBuilder.AddColumn(
name: "Started",
table: "DeploymentJobSteps",
type: "datetime2",
nullable: true)
.Annotation("Relational:ColumnOrder", 11);
migrationBuilder.AlterColumn(
name: "Status",
table: "DeploymentJobs",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AddColumn(
name: "CorrelationId",
table: "DeploymentJobs",
type: "uniqueidentifier",
nullable: false,
defaultValueSql: "NEWID()")
.Annotation("Relational:ColumnOrder", 13);
migrationBuilder.AddColumn(
name: "HeartbeatAt",
table: "DeploymentJobs",
type: "datetime2",
nullable: true)
.Annotation("Relational:ColumnOrder", 16);
migrationBuilder.AddColumn(
name: "Priority",
table: "DeploymentJobs",
type: "int",
nullable: false,
defaultValue: 100)
.Annotation("Relational:ColumnOrder", 14);
migrationBuilder.AddColumn(
name: "RowVersion",
table: "DeploymentJobs",
type: "rowversion",
rowVersion: true,
nullable: false,
defaultValue: new byte[0]);
migrationBuilder.AddColumn(
name: "ScheduledAt",
table: "DeploymentJobs",
type: "datetime2",
nullable: true)
.Annotation("Relational:ColumnOrder", 15);
migrationBuilder.AddColumn(
name: "WorkerName",
table: "DeploymentJobs",
type: "nvarchar(450)",
nullable: true)
.Annotation("Relational:ColumnOrder", 17);
migrationBuilder.CreateIndex(
name: "IX_DeploymentJobTargets_DeploymentJobId_Status",
table: "DeploymentJobTargets",
columns: new[] { "DeploymentJobId", "Status" });
migrationBuilder.AddCheckConstraint(
name: "CK_DeploymentJobTargets_OutputMetadataJson_IsJson",
table: "DeploymentJobTargets",
sql: "[OutputMetadataJson] IS NULL OR ISJSON([OutputMetadataJson]) = 1");
migrationBuilder.CreateIndex(
name: "IX_DeploymentJobSteps_DeploymentJobId_Status_SortOrder",
table: "DeploymentJobSteps",
columns: new[] { "DeploymentJobId", "Status", "SortOrder" });
migrationBuilder.AddCheckConstraint(
name: "CK_DeploymentJobSteps_OutputMetadataJson_IsJson",
table: "DeploymentJobSteps",
sql: "[OutputMetadataJson] IS NULL OR ISJSON([OutputMetadataJson]) = 1");
migrationBuilder.CreateIndex(
name: "IX_DeploymentJobs_CorrelationId",
table: "DeploymentJobs",
column: "CorrelationId");
migrationBuilder.CreateIndex(
name: "IX_DeploymentJobs_Status_ScheduledAt_LockedUntil_Priority_Created",
table: "DeploymentJobs",
columns: new[] { "Status", "ScheduledAt", "LockedUntil", "Priority", "Created" });
migrationBuilder.CreateIndex(
name: "IX_DeploymentJobs_WorkerName",
table: "DeploymentJobs",
column: "WorkerName");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_DeploymentJobTargets_DeploymentJobId_Status",
table: "DeploymentJobTargets");
migrationBuilder.DropCheckConstraint(
name: "CK_DeploymentJobTargets_OutputMetadataJson_IsJson",
table: "DeploymentJobTargets");
migrationBuilder.DropIndex(
name: "IX_DeploymentJobSteps_DeploymentJobId_Status_SortOrder",
table: "DeploymentJobSteps");
migrationBuilder.DropCheckConstraint(
name: "CK_DeploymentJobSteps_OutputMetadataJson_IsJson",
table: "DeploymentJobSteps");
migrationBuilder.DropIndex(
name: "IX_DeploymentJobs_CorrelationId",
table: "DeploymentJobs");
migrationBuilder.DropIndex(
name: "IX_DeploymentJobs_Status_ScheduledAt_LockedUntil_Priority_Created",
table: "DeploymentJobs");
migrationBuilder.DropIndex(
name: "IX_DeploymentJobs_WorkerName",
table: "DeploymentJobs");
migrationBuilder.DropColumn(
name: "Finished",
table: "DeploymentJobTargets");
migrationBuilder.DropColumn(
name: "OutputMetadataJson",
table: "DeploymentJobTargets");
migrationBuilder.DropColumn(
name: "Started",
table: "DeploymentJobTargets");
migrationBuilder.DropColumn(
name: "ErrorMessage",
table: "DeploymentJobSteps");
migrationBuilder.DropColumn(
name: "Finished",
table: "DeploymentJobSteps");
migrationBuilder.DropColumn(
name: "OutputMetadataJson",
table: "DeploymentJobSteps");
migrationBuilder.DropColumn(
name: "Started",
table: "DeploymentJobSteps");
migrationBuilder.DropColumn(
name: "CorrelationId",
table: "DeploymentJobs");
migrationBuilder.DropColumn(
name: "HeartbeatAt",
table: "DeploymentJobs");
migrationBuilder.DropColumn(
name: "Priority",
table: "DeploymentJobs");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "DeploymentJobs");
migrationBuilder.DropColumn(
name: "ScheduledAt",
table: "DeploymentJobs");
migrationBuilder.DropColumn(
name: "WorkerName",
table: "DeploymentJobs");
migrationBuilder.AlterColumn(
name: "Status",
table: "DeploymentJobTargets",
type: "nvarchar(max)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.AlterColumn(
name: "Status",
table: "DeploymentJobSteps",
type: "nvarchar(max)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.AlterColumn(
name: "Status",
table: "DeploymentJobs",
type: "nvarchar(max)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.CreateIndex(
name: "IX_DeploymentJobTargets_DeploymentJobId",
table: "DeploymentJobTargets",
column: "DeploymentJobId");
migrationBuilder.CreateIndex(
name: "IX_DeploymentJobSteps_DeploymentJobId",
table: "DeploymentJobSteps",
column: "DeploymentJobId");
}
}
}