Files
Microsoft.SelfService.Porta…/Migrations/20260516140554_AddDeploymentRulesAndQueueJobSteps.cs

179 lines
8.3 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Microsoft.SelfService.Portal.Core.API.Migrations
{
/// <inheritdoc />
public partial class AddDeploymentRulesAndQueueJobSteps : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "DeploymentRuleId",
table: "Templates",
type: "uniqueidentifier",
nullable: true)
.Annotation("Relational:ColumnOrder", 6);
migrationBuilder.AddColumn<string>(
name: "MetadataJson",
table: "QueueJobs",
type: "nvarchar(max)",
nullable: true)
.Annotation("Relational:ColumnOrder", 11);
migrationBuilder.AddColumn<string>(
name: "RuleSnapshotJson",
table: "QueueJobs",
type: "nvarchar(max)",
nullable: true)
.Annotation("Relational:ColumnOrder", 12);
migrationBuilder.CreateTable(
name: "DeploymentRules",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
Modified = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"),
ModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: false),
Created = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DeploymentRules", x => x.Id);
});
migrationBuilder.CreateTable(
name: "QueueJobSteps",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
QueueJobId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
DependsOnQueueJobStepId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
SortOrder = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
StepType = table.Column<string>(type: "nvarchar(max)", nullable: false),
Status = table.Column<string>(type: "nvarchar(max)", nullable: false),
MetadataJson = table.Column<string>(type: "nvarchar(max)", nullable: true),
ApprovedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
ApprovedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
ApprovalComment = table.Column<string>(type: "nvarchar(max)", nullable: true),
Modified = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"),
ModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: false),
Created = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_QueueJobSteps", x => x.Id);
table.ForeignKey(
name: "FK_QueueJobSteps_QueueJobSteps_DependsOnQueueJobStepId",
column: x => x.DependsOnQueueJobStepId,
principalTable: "QueueJobSteps",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_QueueJobSteps_QueueJobs_QueueJobId",
column: x => x.QueueJobId,
principalTable: "QueueJobs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "DeploymentRuleSteps",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
DeploymentRuleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
SortOrder = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
StepType = table.Column<string>(type: "nvarchar(max)", nullable: false),
RequiresApproval = table.Column<bool>(type: "bit", nullable: false),
MetadataJson = table.Column<string>(type: "nvarchar(max)", nullable: true),
Modified = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"),
ModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: false),
Created = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DeploymentRuleSteps", x => x.Id);
table.ForeignKey(
name: "FK_DeploymentRuleSteps_DeploymentRules_DeploymentRuleId",
column: x => x.DeploymentRuleId,
principalTable: "DeploymentRules",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Templates_DeploymentRuleId",
table: "Templates",
column: "DeploymentRuleId");
migrationBuilder.CreateIndex(
name: "IX_DeploymentRuleSteps_DeploymentRuleId",
table: "DeploymentRuleSteps",
column: "DeploymentRuleId");
migrationBuilder.CreateIndex(
name: "IX_QueueJobSteps_DependsOnQueueJobStepId",
table: "QueueJobSteps",
column: "DependsOnQueueJobStepId");
migrationBuilder.CreateIndex(
name: "IX_QueueJobSteps_QueueJobId",
table: "QueueJobSteps",
column: "QueueJobId");
migrationBuilder.AddForeignKey(
name: "FK_Templates_DeploymentRules_DeploymentRuleId",
table: "Templates",
column: "DeploymentRuleId",
principalTable: "DeploymentRules",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Templates_DeploymentRules_DeploymentRuleId",
table: "Templates");
migrationBuilder.DropTable(
name: "DeploymentRuleSteps");
migrationBuilder.DropTable(
name: "QueueJobSteps");
migrationBuilder.DropTable(
name: "DeploymentRules");
migrationBuilder.DropIndex(
name: "IX_Templates_DeploymentRuleId",
table: "Templates");
migrationBuilder.DropColumn(
name: "DeploymentRuleId",
table: "Templates");
migrationBuilder.DropColumn(
name: "MetadataJson",
table: "QueueJobs");
migrationBuilder.DropColumn(
name: "RuleSnapshotJson",
table: "QueueJobs");
}
}
}