123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- 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<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
- Image = table.Column<string>(type: "nvarchar(max)", nullable: true),
- ParentCategoryID = table.Column<int>(type: "int", nullable: true),
- InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false),
- UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
- IsRemoved = table.Column<bool>(type: "bit", nullable: false),
- RemoveTime = table.Column<DateTime>(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<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
- Brand = table.Column<string>(type: "nvarchar(max)", nullable: true),
- Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
- Price = table.Column<int>(type: "int", nullable: false),
- Inventory = table.Column<int>(type: "int", nullable: false),
- Displayed = table.Column<bool>(type: "bit", nullable: false),
- ViewCount = table.Column<int>(type: "int", nullable: false),
- CategoryID = table.Column<int>(type: "int", nullable: false),
- InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false),
- UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
- IsRemoved = table.Column<bool>(type: "bit", nullable: false),
- RemoveTime = table.Column<DateTime>(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<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- ProductID = table.Column<int>(type: "int", nullable: false),
- DisplayName = table.Column<string>(type: "nvarchar(max)", nullable: true),
- Value = table.Column<string>(type: "nvarchar(max)", nullable: true),
- InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false),
- UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
- IsRemoved = table.Column<bool>(type: "bit", nullable: false),
- RemoveTime = table.Column<DateTime>(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<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- ProductID = table.Column<int>(type: "int", nullable: false),
- Src = table.Column<string>(type: "nvarchar(max)", nullable: true),
- InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false),
- UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
- IsRemoved = table.Column<bool>(type: "bit", nullable: false),
- RemoveTime = table.Column<DateTime>(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");
- }
- }
- }
|