188 lines
8.6 KiB
C#
188 lines
8.6 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class u08 : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Categorys",
|
|
schema: "CMS",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
ImagePath = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
ParentId = table.Column<long>(type: "bigint", nullable: true),
|
|
IsActive = table.Column<bool>(type: "bit", nullable: false),
|
|
SortOrder = table.Column<int>(type: "int", nullable: false),
|
|
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Categorys", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Categorys_Categorys_ParentId",
|
|
column: x => x.ParentId,
|
|
principalSchema: "CMS",
|
|
principalTable: "Categorys",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Tags",
|
|
schema: "CMS",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
IsActive = table.Column<bool>(type: "bit", nullable: false),
|
|
SortOrder = table.Column<int>(type: "int", nullable: false),
|
|
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Tags", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PruductCategorys",
|
|
schema: "CMS",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ProductId = table.Column<long>(type: "bigint", nullable: false),
|
|
CategoryId = table.Column<long>(type: "bigint", nullable: false),
|
|
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PruductCategorys", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_PruductCategorys_Categorys_CategoryId",
|
|
column: x => x.CategoryId,
|
|
principalSchema: "CMS",
|
|
principalTable: "Categorys",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_PruductCategorys_Productss_ProductId",
|
|
column: x => x.ProductId,
|
|
principalSchema: "CMS",
|
|
principalTable: "Productss",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PruductTags",
|
|
schema: "CMS",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ProductId = table.Column<long>(type: "bigint", nullable: false),
|
|
TagId = table.Column<long>(type: "bigint", nullable: false),
|
|
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PruductTags", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_PruductTags_Productss_ProductId",
|
|
column: x => x.ProductId,
|
|
principalSchema: "CMS",
|
|
principalTable: "Productss",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_PruductTags_Tags_TagId",
|
|
column: x => x.TagId,
|
|
principalSchema: "CMS",
|
|
principalTable: "Tags",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Categorys_ParentId",
|
|
schema: "CMS",
|
|
table: "Categorys",
|
|
column: "ParentId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PruductCategorys_CategoryId",
|
|
schema: "CMS",
|
|
table: "PruductCategorys",
|
|
column: "CategoryId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PruductCategorys_ProductId",
|
|
schema: "CMS",
|
|
table: "PruductCategorys",
|
|
column: "ProductId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PruductTags_ProductId",
|
|
schema: "CMS",
|
|
table: "PruductTags",
|
|
column: "ProductId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PruductTags_TagId",
|
|
schema: "CMS",
|
|
table: "PruductTags",
|
|
column: "TagId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "PruductCategorys",
|
|
schema: "CMS");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PruductTags",
|
|
schema: "CMS");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Categorys",
|
|
schema: "CMS");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Tags",
|
|
schema: "CMS");
|
|
}
|
|
}
|
|
}
|