193 lines
12 KiB
C#
193 lines
12 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
|
|
|
namespace Microsoft.SelfService.Portal.Core.API.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddDeploymentComposition : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "DeploymentTargetAssignments",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
DeploymentGroupId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
VirtualMachineId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
RoleKey = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
SortOrder = table.Column<int>(type: "int", nullable: false),
|
|
NodeDataJson = table.Column<string>(type: "nvarchar(max)", 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_DeploymentTargetAssignments", x => x.Id);
|
|
table.CheckConstraint("CK_DeploymentTargetAssignments_NodeDataJson_IsJson", "ISJSON([NodeDataJson]) = 1");
|
|
table.ForeignKey(
|
|
name: "FK_DeploymentTargetAssignments_DeploymentBatches_DeploymentGroupId",
|
|
column: x => x.DeploymentGroupId,
|
|
principalTable: "DeploymentBatches",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_DeploymentTargetAssignments_VirtualMachines_VirtualMachineId",
|
|
column: x => x.VirtualMachineId,
|
|
principalTable: "VirtualMachines",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DeploymentTemplateSelections",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
DeploymentGroupId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
TemplateVersionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
TemplateRole = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
SortOrder = table.Column<int>(type: "int", nullable: false),
|
|
Alias = 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_DeploymentTemplateSelections", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_DeploymentTemplateSelections_DeploymentBatches_DeploymentGroupId",
|
|
column: x => x.DeploymentGroupId,
|
|
principalTable: "DeploymentBatches",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_DeploymentTemplateSelections_TemplateVersions_TemplateVersionId",
|
|
column: x => x.TemplateVersionId,
|
|
principalTable: "TemplateVersions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DeploymentParameterValues",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
DeploymentGroupId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
DeploymentTemplateSelectionId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
|
Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
ValueJson = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
IsSecretReference = table.Column<bool>(type: "bit", nullable: false),
|
|
IsOverride = 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_DeploymentParameterValues", x => x.Id);
|
|
table.CheckConstraint("CK_DeploymentParameterValues_ValueJson_IsJson", "ISJSON([ValueJson]) = 1");
|
|
table.ForeignKey(
|
|
name: "FK_DeploymentParameterValues_DeploymentBatches_DeploymentGroupId",
|
|
column: x => x.DeploymentGroupId,
|
|
principalTable: "DeploymentBatches",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_DeploymentParameterValues_DeploymentTemplateSelections_DeploymentTemplateSelectionId",
|
|
column: x => x.DeploymentTemplateSelectionId,
|
|
principalTable: "DeploymentTemplateSelections",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.InsertData(
|
|
table: "DeploymentTargetAssignments",
|
|
columns: new[] { "Id", "Created", "CreatedBy", "DeploymentGroupId", "Modified", "ModifiedBy", "NodeDataJson", "RoleKey", "SortOrder", "VirtualMachineId" },
|
|
values: new object[,]
|
|
{
|
|
{ new Guid("84000000-0000-0000-0000-000000000001"), new DateTime(2026, 7, 7, 0, 0, 0, 0, DateTimeKind.Utc), "DemoSeed", new Guid("80000000-0000-0000-0000-000000000001"), new DateTime(2026, 7, 7, 0, 0, 0, 0, DateTimeKind.Utc), "DemoSeed", "{\"nodeName\":\"CT-SHP-01\"}", "WebFrontEnd", 10, new Guid("30000000-0000-0000-0000-000000000004") },
|
|
{ new Guid("84000000-0000-0000-0000-000000000002"), new DateTime(2026, 7, 7, 0, 0, 0, 0, DateTimeKind.Utc), "DemoSeed", new Guid("80000000-0000-0000-0000-000000000001"), new DateTime(2026, 7, 7, 0, 0, 0, 0, DateTimeKind.Utc), "DemoSeed", "{\"nodeName\":\"CT-SHP-02\"}", "Application", 20, new Guid("30000000-0000-0000-0000-000000000005") }
|
|
});
|
|
|
|
migrationBuilder.InsertData(
|
|
table: "DeploymentTemplateSelections",
|
|
columns: new[] { "Id", "Alias", "Created", "CreatedBy", "DeploymentGroupId", "Modified", "ModifiedBy", "SortOrder", "TemplateRole", "TemplateVersionId" },
|
|
values: new object[] { new Guid("82000000-0000-0000-0000-000000000001"), "SharePoint", new DateTime(2026, 7, 7, 0, 0, 0, 0, DateTimeKind.Utc), "DemoSeed", new Guid("80000000-0000-0000-0000-000000000001"), new DateTime(2026, 7, 7, 0, 0, 0, 0, DateTimeKind.Utc), "DemoSeed", 10, "Service", new Guid("71000000-0000-0000-0000-000000000003") });
|
|
|
|
migrationBuilder.InsertData(
|
|
table: "DeploymentParameterValues",
|
|
columns: new[] { "Id", "Created", "CreatedBy", "DeploymentGroupId", "DeploymentTemplateSelectionId", "IsOverride", "IsSecretReference", "Modified", "ModifiedBy", "Name", "ValueJson" },
|
|
values: new object[,]
|
|
{
|
|
{ new Guid("83000000-0000-0000-0000-000000000001"), new DateTime(2026, 7, 7, 0, 0, 0, 0, DateTimeKind.Utc), "DemoSeed", new Guid("80000000-0000-0000-0000-000000000001"), new Guid("82000000-0000-0000-0000-000000000001"), true, false, new DateTime(2026, 7, 7, 0, 0, 0, 0, DateTimeKind.Utc), "DemoSeed", "DatabasePrefix", "{\"value\":\"SharePoint_Contoso_Test\"}" },
|
|
{ new Guid("83000000-0000-0000-0000-000000000002"), new DateTime(2026, 7, 7, 0, 0, 0, 0, DateTimeKind.Utc), "DemoSeed", new Guid("80000000-0000-0000-0000-000000000001"), new Guid("82000000-0000-0000-0000-000000000001"), true, true, new DateTime(2026, 7, 7, 0, 0, 0, 0, DateTimeKind.Utc), "DemoSeed", "FarmAccount", "{\"provider\":\"SecretManagement\",\"vault\":\"ContosoDemo\",\"name\":\"Windows/SharePoint/FarmAccount\"}" }
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeploymentParameterValues_DeploymentGroupId_DeploymentTemplateSelectionId_Name",
|
|
table: "DeploymentParameterValues",
|
|
columns: new[] { "DeploymentGroupId", "DeploymentTemplateSelectionId", "Name" },
|
|
unique: true,
|
|
filter: "[DeploymentTemplateSelectionId] IS NOT NULL");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeploymentParameterValues_DeploymentGroupId_Name",
|
|
table: "DeploymentParameterValues",
|
|
columns: new[] { "DeploymentGroupId", "Name" },
|
|
unique: true,
|
|
filter: "[DeploymentTemplateSelectionId] IS NULL");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeploymentParameterValues_DeploymentTemplateSelectionId",
|
|
table: "DeploymentParameterValues",
|
|
column: "DeploymentTemplateSelectionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeploymentTargetAssignments_DeploymentGroupId_VirtualMachineId_RoleKey",
|
|
table: "DeploymentTargetAssignments",
|
|
columns: new[] { "DeploymentGroupId", "VirtualMachineId", "RoleKey" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeploymentTargetAssignments_VirtualMachineId",
|
|
table: "DeploymentTargetAssignments",
|
|
column: "VirtualMachineId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeploymentTemplateSelections_DeploymentGroupId_SortOrder",
|
|
table: "DeploymentTemplateSelections",
|
|
columns: new[] { "DeploymentGroupId", "SortOrder" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeploymentTemplateSelections_TemplateVersionId",
|
|
table: "DeploymentTemplateSelections",
|
|
column: "TemplateVersionId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "DeploymentParameterValues");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "DeploymentTargetAssignments");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "DeploymentTemplateSelections");
|
|
}
|
|
}
|
|
}
|