using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace SPMS.Infrastructure.Migrations { /// public partial class AddPublicApiTables : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "AppConfig", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), ServiceId = table.Column(type: "bigint", nullable: false), ConfigKey = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ConfigValue = table.Column(type: "text", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreatedAt = table.Column(type: "datetime(6)", nullable: false), UpdatedAt = table.Column(type: "datetime(6)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AppConfig", x => x.Id); table.ForeignKey( name: "FK_AppConfig_Service_ServiceId", column: x => x.ServiceId, principalTable: "Service", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Banner", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), ServiceId = table.Column(type: "bigint", nullable: false), Title = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ImageUrl = table.Column(type: "varchar(500)", maxLength: 500, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), LinkUrl = table.Column(type: "varchar(500)", maxLength: 500, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), LinkType = table.Column(type: "varchar(20)", maxLength: 20, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Position = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), SortOrder = table.Column(type: "int", nullable: false), IsActive = table.Column(type: "tinyint(1)", nullable: false, defaultValue: true), CreatedAt = table.Column(type: "datetime(6)", nullable: false), UpdatedAt = table.Column(type: "datetime(6)", nullable: true), IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false) }, constraints: table => { table.PrimaryKey("PK_Banner", x => x.Id); table.ForeignKey( name: "FK_Banner_Service_ServiceId", column: x => x.ServiceId, principalTable: "Service", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Faq", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), ServiceId = table.Column(type: "bigint", nullable: false), Category = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Question = table.Column(type: "varchar(500)", maxLength: 500, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Answer = table.Column(type: "text", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), SortOrder = table.Column(type: "int", nullable: false), IsActive = table.Column(type: "tinyint(1)", nullable: false, defaultValue: true), CreatedAt = table.Column(type: "datetime(6)", nullable: false), UpdatedAt = table.Column(type: "datetime(6)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Faq", x => x.Id); table.ForeignKey( name: "FK_Faq_Service_ServiceId", column: x => x.ServiceId, principalTable: "Service", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Notice", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), ServiceId = table.Column(type: "bigint", nullable: false), Title = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Content = table.Column(type: "text", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), IsPinned = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), IsActive = table.Column(type: "tinyint(1)", nullable: false, defaultValue: true), CreatedAt = table.Column(type: "datetime(6)", nullable: false), CreatedBy = table.Column(type: "bigint", nullable: false), UpdatedAt = table.Column(type: "datetime(6)", nullable: true), IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false) }, constraints: table => { table.PrimaryKey("PK_Notice", x => x.Id); table.ForeignKey( name: "FK_Notice_Admin_CreatedBy", column: x => x.CreatedBy, principalTable: "Admin", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Notice_Service_ServiceId", column: x => x.ServiceId, principalTable: "Service", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_AppConfig_ServiceId_ConfigKey", table: "AppConfig", columns: new[] { "ServiceId", "ConfigKey" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Banner_ServiceId", table: "Banner", column: "ServiceId"); migrationBuilder.CreateIndex( name: "IX_Faq_ServiceId", table: "Faq", column: "ServiceId"); migrationBuilder.CreateIndex( name: "IX_Notice_CreatedBy", table: "Notice", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Notice_ServiceId", table: "Notice", column: "ServiceId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AppConfig"); migrationBuilder.DropTable( name: "Banner"); migrationBuilder.DropTable( name: "Faq"); migrationBuilder.DropTable( name: "Notice"); } } }