using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Distribution.Migrations { /// public partial class AddNotifications : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Notifications", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Type = table.Column(type: "varchar(60)", maxLength: 60, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Severity = table.Column(type: "int", nullable: false), Title = table.Column(type: "varchar(150)", maxLength: 150, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Message = table.Column(type: "varchar(500)", maxLength: 500, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), EntityType = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), EntityId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Link = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), CreatedByUserId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), CreatedAt = table.Column(type: "datetime(6)", nullable: false), IsActive = table.Column(type: "tinyint(1)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Notifications", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "NotificationRecipients", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), FK_NotificationId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), FK_UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), IsRead = table.Column(type: "tinyint(1)", nullable: false), ReadAt = table.Column(type: "datetime(6)", nullable: true), CreatedAt = table.Column(type: "datetime(6)", nullable: false), IsActive = table.Column(type: "tinyint(1)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_NotificationRecipients", x => x.Id); table.ForeignKey( name: "FK_NotificationRecipients_Notifications_FK_NotificationId", column: x => x.FK_NotificationId, principalTable: "Notifications", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_NotificationRecipients_Users_FK_UserId", column: x => x.FK_UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_NotificationRecipients_FK_NotificationId_FK_UserId", table: "NotificationRecipients", columns: new[] { "FK_NotificationId", "FK_UserId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_NotificationRecipients_FK_UserId_IsRead", table: "NotificationRecipients", columns: new[] { "FK_UserId", "IsRead" }); migrationBuilder.CreateIndex( name: "IX_Notifications_EntityType_EntityId", table: "Notifications", columns: new[] { "EntityType", "EntityId" }); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "NotificationRecipients"); migrationBuilder.DropTable( name: "Notifications"); } } }