153 lines
5.9 KiB
C#
153 lines
5.9 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Project.Web.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Initial : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "CATEGORY",
|
|
columns: table => new
|
|
{
|
|
ID = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
CATEGORY_NAME = table.Column<int>(type: "int", nullable: false),
|
|
CREATION_DATE = table.Column<DateTime>(type: "datetime", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CATEGORY", x => x.ID);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ROLE",
|
|
columns: table => new
|
|
{
|
|
ID = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ROLE = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
CREATION_DATE = table.Column<DateTime>(type: "datetime", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ROLE", x => x.ID);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PRODUCT",
|
|
columns: table => new
|
|
{
|
|
ID = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
PRODUCT_NAME = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
CREATION_DATE = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
CategoryId = table.Column<int>(type: "int", nullable: false),
|
|
QUANTITY = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PRODUCT", x => x.ID);
|
|
table.ForeignKey(
|
|
name: "FK_PRODUCT_CATEGORY_CategoryId",
|
|
column: x => x.CategoryId,
|
|
principalTable: "CATEGORY",
|
|
principalColumn: "ID",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "CATEGORY_ROLE",
|
|
columns: table => new
|
|
{
|
|
ID = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
CategoryId = table.Column<int>(type: "int", nullable: false),
|
|
RoleId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CATEGORY_ROLE", x => x.ID);
|
|
table.ForeignKey(
|
|
name: "FK_CATEGORY_ROLE_CATEGORY_CategoryId",
|
|
column: x => x.CategoryId,
|
|
principalTable: "CATEGORY",
|
|
principalColumn: "ID",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_CATEGORY_ROLE_ROLE_RoleId",
|
|
column: x => x.RoleId,
|
|
principalTable: "ROLE",
|
|
principalColumn: "ID",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "USER",
|
|
columns: table => new
|
|
{
|
|
ID = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
USER_NAME = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
FIRST_NAME = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
LAST_NAME = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
RoleId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_USER", x => x.ID);
|
|
table.ForeignKey(
|
|
name: "FK_USER_ROLE_RoleId",
|
|
column: x => x.RoleId,
|
|
principalTable: "ROLE",
|
|
principalColumn: "ID",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CATEGORY_ROLE_CategoryId",
|
|
table: "CATEGORY_ROLE",
|
|
column: "CategoryId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CATEGORY_ROLE_RoleId",
|
|
table: "CATEGORY_ROLE",
|
|
column: "RoleId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PRODUCT_CategoryId",
|
|
table: "PRODUCT",
|
|
column: "CategoryId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_USER_RoleId",
|
|
table: "USER",
|
|
column: "RoleId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "CATEGORY_ROLE");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PRODUCT");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "USER");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "CATEGORY");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ROLE");
|
|
}
|
|
}
|
|
}
|