469 lines
24 KiB
C#
469 lines
24 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Microsoft.SelfService.Portal.Core.API.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Initial : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Domains",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
FQDN = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
NetBIOS = 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_Domains", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Environments",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
CloudEnabled = 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_Environments", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "OptionCategories",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
ParentCategoryName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
showOrder = table.Column<int>(type: "int", 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_OptionCategories", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Runbooks",
|
|
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: 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_Runbooks", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Services",
|
|
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: 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_Services", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "VirtualMachines",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
DomainID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
Name = 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_VirtualMachines", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_VirtualMachines_Domains_DomainID",
|
|
column: x => x.DomainID,
|
|
principalTable: "Domains",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "EnvironmentDomains",
|
|
columns: table => new
|
|
{
|
|
EnvironmentId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
DomainId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
Modified = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
ModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_EnvironmentDomains", x => new { x.EnvironmentId, x.DomainId });
|
|
table.ForeignKey(
|
|
name: "FK_EnvironmentDomains_Domains_DomainId",
|
|
column: x => x.DomainId,
|
|
principalTable: "Domains",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_EnvironmentDomains_Environments_EnvironmentId",
|
|
column: x => x.EnvironmentId,
|
|
principalTable: "Environments",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Options",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
OptionType = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
OptionValue = 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),
|
|
OptionCategoryId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Options", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Options_OptionCategories_OptionCategoryId",
|
|
column: x => x.OptionCategoryId,
|
|
principalTable: "OptionCategories",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Events",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
RunbookId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
Class = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Method = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
RestEndpointMethod = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
RestEndpointOperation = 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_Events", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Events_Runbooks_RunbookId",
|
|
column: x => x.RunbookId,
|
|
principalTable: "Runbooks",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "TemplateCategories",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
ServiceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
ParentCategoryName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
showOrder = table.Column<int>(type: "int", 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_TemplateCategories", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_TemplateCategories_Services_ServiceId",
|
|
column: x => x.ServiceId,
|
|
principalTable: "Services",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Templates",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
CloudTemplate = table.Column<bool>(type: "bit", nullable: false),
|
|
Version = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
JSONData = 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),
|
|
TemplateCategoryId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Templates", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Templates_TemplateCategories_TemplateCategoryId",
|
|
column: x => x.TemplateCategoryId,
|
|
principalTable: "TemplateCategories",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DeploymentGroups",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
TemplateId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
Status = table.Column<string>(type: "nvarchar(max)", nullable: false, defaultValueSql: "'New'"),
|
|
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_DeploymentGroups", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_DeploymentGroups_Templates_TemplateId",
|
|
column: x => x.TemplateId,
|
|
principalTable: "Templates",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "TemplateOptions",
|
|
columns: table => new
|
|
{
|
|
TemplateId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
OptionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
Value = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Modified = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
ModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_TemplateOptions", x => new { x.OptionId, x.TemplateId });
|
|
table.ForeignKey(
|
|
name: "FK_TemplateOptions_Options_OptionId",
|
|
column: x => x.OptionId,
|
|
principalTable: "Options",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_TemplateOptions_Templates_TemplateId",
|
|
column: x => x.TemplateId,
|
|
principalTable: "Templates",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Deployments",
|
|
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),
|
|
Status = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
JSONData = 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_Deployments", x => new { x.VirtualMachineId, x.DeploymentGroupId });
|
|
table.UniqueConstraint("AK_Deployments_Id", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Deployments_DeploymentGroups_DeploymentGroupId",
|
|
column: x => x.DeploymentGroupId,
|
|
principalTable: "DeploymentGroups",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Deployments_VirtualMachines_VirtualMachineId",
|
|
column: x => x.VirtualMachineId,
|
|
principalTable: "VirtualMachines",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Jobs",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
DeploymentId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
RunbookId = table.Column<Guid>(type: "uniqueidentifier", 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_Jobs", x => new { x.RunbookId, x.DeploymentId });
|
|
table.ForeignKey(
|
|
name: "FK_Jobs_Deployments_DeploymentId",
|
|
column: x => x.DeploymentId,
|
|
principalTable: "Deployments",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Jobs_Runbooks_RunbookId",
|
|
column: x => x.RunbookId,
|
|
principalTable: "Runbooks",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeploymentGroups_TemplateId",
|
|
table: "DeploymentGroups",
|
|
column: "TemplateId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Deployments_DeploymentGroupId",
|
|
table: "Deployments",
|
|
column: "DeploymentGroupId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_EnvironmentDomains_DomainId",
|
|
table: "EnvironmentDomains",
|
|
column: "DomainId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Events_RunbookId",
|
|
table: "Events",
|
|
column: "RunbookId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Jobs_DeploymentId",
|
|
table: "Jobs",
|
|
column: "DeploymentId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Options_OptionCategoryId",
|
|
table: "Options",
|
|
column: "OptionCategoryId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_TemplateCategories_ServiceId",
|
|
table: "TemplateCategories",
|
|
column: "ServiceId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_TemplateOptions_TemplateId",
|
|
table: "TemplateOptions",
|
|
column: "TemplateId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Templates_TemplateCategoryId",
|
|
table: "Templates",
|
|
column: "TemplateCategoryId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_VirtualMachines_DomainID",
|
|
table: "VirtualMachines",
|
|
column: "DomainID");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "EnvironmentDomains");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Events");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Jobs");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "TemplateOptions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Environments");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Deployments");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Runbooks");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Options");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "DeploymentGroups");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "VirtualMachines");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "OptionCategories");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Templates");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Domains");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "TemplateCategories");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Services");
|
|
}
|
|
}
|
|
}
|