using System; using BTCPayServer.Data; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; namespace BTCPayServer.Migrations { [DbContext(typeof(ApplicationDbContext))] [Migration("20201108054749_webhooks")] public partial class webhooks : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Webhooks", columns: table => new { Id = table.Column(maxLength: 25, nullable: false), Blob = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Webhooks", x => x.Id); }); migrationBuilder.CreateTable( name: "StoreWebhooks", columns: table => new { StoreId = table.Column(maxLength: 50, nullable: false), WebhookId = table.Column(maxLength: 25, nullable: false) }, constraints: table => { table.PrimaryKey("PK_StoreWebhooks", x => new { x.StoreId, x.WebhookId }); table.ForeignKey( name: "FK_StoreWebhooks_Stores_StoreId", column: x => x.StoreId, principalTable: "Stores", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_StoreWebhooks_Webhooks_WebhookId", column: x => x.WebhookId, principalTable: "Webhooks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "WebhookDeliveries", columns: table => new { Id = table.Column(maxLength: 25, nullable: false), WebhookId = table.Column(maxLength: 25, nullable: false), Timestamp = table.Column(nullable: false), Blob = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_WebhookDeliveries", x => x.Id); table.ForeignKey( name: "FK_WebhookDeliveries_Webhooks_WebhookId", column: x => x.WebhookId, principalTable: "Webhooks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "InvoiceWebhookDeliveries", columns: table => new { InvoiceId = table.Column(maxLength: 255, nullable: false), DeliveryId = table.Column(maxLength: 100, nullable: false) }, constraints: table => { table.PrimaryKey("PK_InvoiceWebhookDeliveries", x => new { x.InvoiceId, x.DeliveryId }); table.ForeignKey( name: "FK_InvoiceWebhookDeliveries_WebhookDeliveries_DeliveryId", column: x => x.DeliveryId, principalTable: "WebhookDeliveries", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_InvoiceWebhookDeliveries_Invoices_InvoiceId", column: x => x.InvoiceId, principalTable: "Invoices", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_WebhookDeliveries_WebhookId", table: "WebhookDeliveries", column: "WebhookId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "InvoiceWebhookDeliveries"); migrationBuilder.DropTable( name: "StoreWebhooks"); migrationBuilder.DropTable( name: "WebhookDeliveries"); migrationBuilder.DropTable( name: "Webhooks"); } } }