using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Diligent.WebAPI.Data.Migrations { public partial class AddedWebhookTables : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "WebhookDefinitions", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), DisplayName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: false), CreatedAtUtc = table.Column(type: "datetime2", nullable: false), UpdatedAtUtc = table.Column(type: "datetime2", nullable: true), DeletedAtUtc = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_WebhookDefinitions", x => x.Id); }); migrationBuilder.CreateTable( name: "WebhookSubscriptions", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), WebhookURL = table.Column(type: "nvarchar(max)", nullable: false), IsActive = table.Column(type: "bit", nullable: false), WebhookDefinitionId = table.Column(type: "bigint", nullable: false), CreatedAtUtc = table.Column(type: "datetime2", nullable: false), UpdatedAtUtc = table.Column(type: "datetime2", nullable: true), DeletedAtUtc = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_WebhookSubscriptions", x => x.Id); table.ForeignKey( name: "FK_WebhookSubscriptions_WebhookDefinitions_WebhookDefinitionId", column: x => x.WebhookDefinitionId, principalTable: "WebhookDefinitions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_WebhookSubscriptions_WebhookDefinitionId", table: "WebhookSubscriptions", column: "WebhookDefinitionId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "WebhookSubscriptions"); migrationBuilder.DropTable( name: "WebhookDefinitions"); } } }