using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Microsoft.SelfService.Portal.Core.API.Migrations { /// public partial class RemoveSmaRunbooks : Migration { /// 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"); } /// 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(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"), Name = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: false), Modified = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"), ModifiedBy = table.Column(type: "nvarchar(max)", nullable: false), Created = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"), CreatedBy = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Runbooks", x => x.Id); }); migrationBuilder.CreateTable( name: "Events", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"), RunbookId = table.Column(type: "uniqueidentifier", nullable: false), Class = table.Column(type: "nvarchar(max)", nullable: false), Method = table.Column(type: "nvarchar(max)", nullable: false), RestEndpointMethod = table.Column(type: "nvarchar(max)", nullable: false), RestEndpointOperation = table.Column(type: "nvarchar(max)", nullable: false), Modified = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"), ModifiedBy = table.Column(type: "nvarchar(max)", nullable: false), Created = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"), CreatedBy = table.Column(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(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"), DeploymentId = table.Column(type: "uniqueidentifier", nullable: false), RunbookId = table.Column(type: "uniqueidentifier", nullable: false), Modified = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"), ModifiedBy = table.Column(type: "nvarchar(max)", nullable: false), Created = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"), CreatedBy = table.Column(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"); } } }