using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace LY.MicroService.WebhooksManagement.Migrations { public partial class AddModuleWebHooksManagement : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "WebhooksManagement_WebhookEvents", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), WebhookName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Data = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreationTime = table.Column(type: "datetime(6)", nullable: false), DeletionTime = table.Column(type: "datetime(6)", nullable: true), IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false) }, constraints: table => { table.PrimaryKey("PK_WebhooksManagement_WebhookEvents", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "WebhooksManagement_WebhookSubscriptions", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), WebhookUri = table.Column(type: "varchar(255)", maxLength: 255, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Secret = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), IsActive = table.Column(type: "tinyint(1)", nullable: false), Webhooks = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Headers = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreationTime = table.Column(type: "datetime(6)", nullable: false), CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_WebhooksManagement_WebhookSubscriptions", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "WebhooksManagement_WebhookSendAttempts", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), WebhookEventId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), WebhookSubscriptionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Response = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ResponseStatusCode = table.Column(type: "int", nullable: true), CreationTime = table.Column(type: "datetime(6)", nullable: false), LastModificationTime = table.Column(type: "datetime(6)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_WebhooksManagement_WebhookSendAttempts", x => x.Id); table.ForeignKey( name: "FK_WebhooksManagement_WebhookSendAttempts_WebhooksManagement_We~", column: x => x.WebhookEventId, principalTable: "WebhooksManagement_WebhookEvents", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_WebhooksManagement_WebhookSendAttempts_WebhookEventId", table: "WebhooksManagement_WebhookSendAttempts", column: "WebhookEventId", unique: true); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "WebhooksManagement_WebhookSendAttempts"); migrationBuilder.DropTable( name: "WebhooksManagement_WebhookSubscriptions"); migrationBuilder.DropTable( name: "WebhooksManagement_WebhookEvents"); } } }