using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace bitforum.Migrations.DefaultDb { /// public partial class AddFaqs : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Document", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), IsDisplay = table.Column(type: "bit", nullable: false), Code = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false), Subject = table.Column(type: "nvarchar(120)", maxLength: 120, nullable: false), Content = table.Column(type: "nvarchar(max)", nullable: true), Views = table.Column(type: "int", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Document", x => x.ID); }); migrationBuilder.CreateTable( name: "FaqCategory", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Code = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false), Subject = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), Content = table.Column(type: "nvarchar(max)", nullable: true), Order = table.Column(type: "int", nullable: false), IsActive = table.Column(type: "bit", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_FaqCategory", x => x.ID); }); migrationBuilder.CreateTable( name: "FaqItem", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CategoryID = table.Column(type: "int", nullable: false), Question = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), Answer = table.Column(type: "nvarchar(max)", nullable: true), Order = table.Column(type: "int", nullable: false), IsActive = table.Column(type: "bit", nullable: false), Views = table.Column(type: "int", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_FaqItem", x => x.ID); table.ForeignKey( name: "FK_FaqItem_FaqCategory_CategoryID", column: x => x.CategoryID, principalTable: "FaqCategory", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Document_Code", table: "Document", column: "Code", unique: true); migrationBuilder.CreateIndex( name: "IX_FaqCategory_Code", table: "FaqCategory", column: "Code", unique: true); migrationBuilder.CreateIndex( name: "IX_FaqCategory_Order", table: "FaqCategory", column: "Order"); migrationBuilder.CreateIndex( name: "IX_FaqItem_CategoryID", table: "FaqItem", column: "CategoryID"); migrationBuilder.CreateIndex( name: "IX_FaqItem_IsActive", table: "FaqItem", column: "IsActive"); migrationBuilder.CreateIndex( name: "IX_FaqItem_Order", table: "FaqItem", column: "Order"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Document"); migrationBuilder.DropTable( name: "FaqItem"); migrationBuilder.DropTable( name: "FaqCategory"); } } }