using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace SPMS.Infrastructure.Migrations { /// public partial class AddNotificationTable : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Notification", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TargetAdminId = table.Column(type: "bigint", nullable: false), Category = table.Column(type: "tinyint unsigned", nullable: false), Title = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Content = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), LinkUrl = table.Column(type: "varchar(500)", maxLength: 500, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), IsRead = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), ReadAt = table.Column(type: "datetime(6)", nullable: true), CreatedAt = table.Column(type: "datetime(6)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Notification", x => x.Id); table.ForeignKey( name: "FK_Notification_Admin_TargetAdminId", column: x => x.TargetAdminId, principalTable: "Admin", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_Notification_TargetAdminId_CreatedAt", table: "Notification", columns: new[] { "TargetAdminId", "CreatedAt" }); migrationBuilder.CreateIndex( name: "IX_Notification_TargetAdminId_IsRead", table: "Notification", columns: new[] { "TargetAdminId", "IsRead" }); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Notification"); } } }