using System; using Microsoft.EntityFrameworkCore.Migrations; namespace Karsha_Site.Persistance.Migrations { public partial class Category : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Categories", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Title = table.Column(type: "nvarchar(max)", nullable: true), Image = table.Column(type: "nvarchar(max)", nullable: true), ParentCategoryID = table.Column(type: "int", nullable: true), InsertTime = table.Column(type: "datetime2", nullable: false), UpdateTime = table.Column(type: "datetime2", nullable: true), IsRemoved = table.Column(type: "bit", nullable: false), RemoveTime = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Categories", x => x.ID); table.ForeignKey( name: "FK_Categories_Categories_ParentCategoryID", column: x => x.ParentCategoryID, principalTable: "Categories", principalColumn: "ID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Products", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: true), Brand = table.Column(type: "nvarchar(max)", nullable: true), Description = table.Column(type: "nvarchar(max)", nullable: true), Price = table.Column(type: "int", nullable: false), Inventory = table.Column(type: "int", nullable: false), Displayed = table.Column(type: "bit", nullable: false), ViewCount = table.Column(type: "int", nullable: false), CategoryID = table.Column(type: "int", nullable: false), InsertTime = table.Column(type: "datetime2", nullable: false), UpdateTime = table.Column(type: "datetime2", nullable: true), IsRemoved = table.Column(type: "bit", nullable: false), RemoveTime = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Products", x => x.ID); table.ForeignKey( name: "FK_Products_Categories_CategoryID", column: x => x.CategoryID, principalTable: "Categories", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ProductFeatures", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ProductID = table.Column(type: "int", nullable: false), DisplayName = table.Column(type: "nvarchar(max)", nullable: true), Value = table.Column(type: "nvarchar(max)", nullable: true), InsertTime = table.Column(type: "datetime2", nullable: false), UpdateTime = table.Column(type: "datetime2", nullable: true), IsRemoved = table.Column(type: "bit", nullable: false), RemoveTime = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ProductFeatures", x => x.ID); table.ForeignKey( name: "FK_ProductFeatures_Products_ProductID", column: x => x.ProductID, principalTable: "Products", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ProductImages", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ProductID = table.Column(type: "int", nullable: false), Src = table.Column(type: "nvarchar(max)", nullable: true), InsertTime = table.Column(type: "datetime2", nullable: false), UpdateTime = table.Column(type: "datetime2", nullable: true), IsRemoved = table.Column(type: "bit", nullable: false), RemoveTime = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ProductImages", x => x.ID); table.ForeignKey( name: "FK_ProductImages_Products_ProductID", column: x => x.ProductID, principalTable: "Products", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Categories_ParentCategoryID", table: "Categories", column: "ParentCategoryID"); migrationBuilder.CreateIndex( name: "IX_ProductFeatures_ProductID", table: "ProductFeatures", column: "ProductID"); migrationBuilder.CreateIndex( name: "IX_ProductImages_ProductID", table: "ProductImages", column: "ProductID"); migrationBuilder.CreateIndex( name: "IX_Products_CategoryID", table: "Products", column: "CategoryID"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ProductFeatures"); migrationBuilder.DropTable( name: "ProductImages"); migrationBuilder.DropTable( name: "Products"); migrationBuilder.DropTable( name: "Categories"); } } }