120 lines
5.6 KiB
C#
120 lines
5.6 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Microsoft.SelfService.Portal.Core.API.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class RemoveSmaRunbooks : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Events");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Jobs");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Runbooks");
|
|
|
|
migrationBuilder.DropUniqueConstraint(
|
|
name: "AK_DeploymentExecutions_Id",
|
|
table: "DeploymentExecutions");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddUniqueConstraint(
|
|
name: "AK_DeploymentExecutions_Id",
|
|
table: "DeploymentExecutions",
|
|
column: "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: "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: "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_DeploymentExecutions_DeploymentId",
|
|
column: x => x.DeploymentId,
|
|
principalTable: "DeploymentExecutions",
|
|
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_Events_RunbookId",
|
|
table: "Events",
|
|
column: "RunbookId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Jobs_DeploymentId",
|
|
table: "Jobs",
|
|
column: "DeploymentId");
|
|
}
|
|
}
|
|
}
|