using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ElectronicsShopDataBaseImplement.Migrations
{
///
public partial class Init : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
ID = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientFIO = table.Column(type: "nvarchar(max)", nullable: false),
Password = table.Column(type: "nvarchar(max)", nullable: false),
Email = table.Column(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Employees",
columns: table => new
{
ID = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EmployeeFIO = table.Column(type: "nvarchar(max)", nullable: false),
Login = table.Column(type: "nvarchar(max)", nullable: false),
Password = table.Column(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Employees", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Messages",
columns: table => new
{
MessageID = table.Column(type: "nvarchar(450)", nullable: false),
ClientID = table.Column(type: "int", nullable: true),
SenderName = table.Column(type: "nvarchar(max)", nullable: false),
DateDelivery = table.Column(type: "datetime2", nullable: false),
Subject = table.Column(type: "nvarchar(max)", nullable: false),
Body = table.Column(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Messages", x => x.MessageID);
table.ForeignKey(
name: "FK_Messages_Clients_ClientID",
column: x => x.ClientID,
principalTable: "Clients",
principalColumn: "ID");
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
ID = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Sum = table.Column(type: "float", nullable: false),
ClientID = table.Column(type: "int", nullable: false),
DateCreate = table.Column(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.ID);
table.ForeignKey(
name: "FK_Orders_Clients_ClientID",
column: x => x.ClientID,
principalTable: "Clients",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CostItems",
columns: table => new
{
ID = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EmployeeID = table.Column(type: "int", nullable: false),
Name = table.Column(type: "nvarchar(max)", nullable: false),
Price = table.Column(type: "float", nullable: false),
CostNum = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CostItems", x => x.ID);
table.ForeignKey(
name: "FK_CostItems_Employees_EmployeeID",
column: x => x.EmployeeID,
principalTable: "Employees",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Paymeants",
columns: table => new
{
ID = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProductID = table.Column(type: "int", nullable: false),
OrderID = table.Column(type: "int", nullable: false),
SumPayment = table.Column(type: "float", nullable: false),
PayOption = table.Column(type: "int", nullable: false),
PaymentID = table.Column(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Paymeants", x => x.ID);
table.ForeignKey(
name: "FK_Paymeants_Orders_PaymentID",
column: x => x.PaymentID,
principalTable: "Orders",
principalColumn: "ID");
});
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
ID = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProductName = table.Column(type: "nvarchar(max)", nullable: false),
Price = table.Column(type: "float", nullable: false),
CostItemID = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.ID);
table.ForeignKey(
name: "FK_Products_CostItems_CostItemID",
column: x => x.CostItemID,
principalTable: "CostItems",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "OrderProducts",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
OrderID = table.Column(type: "int", nullable: false),
ProductID = table.Column(type: "int", nullable: false),
Count = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrderProducts", x => x.Id);
table.ForeignKey(
name: "FK_OrderProducts_Orders_OrderID",
column: x => x.OrderID,
principalTable: "Orders",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_OrderProducts_Products_ProductID",
column: x => x.ProductID,
principalTable: "Products",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_CostItems_EmployeeID",
table: "CostItems",
column: "EmployeeID");
migrationBuilder.CreateIndex(
name: "IX_Messages_ClientID",
table: "Messages",
column: "ClientID");
migrationBuilder.CreateIndex(
name: "IX_OrderProducts_OrderID",
table: "OrderProducts",
column: "OrderID");
migrationBuilder.CreateIndex(
name: "IX_OrderProducts_ProductID",
table: "OrderProducts",
column: "ProductID");
migrationBuilder.CreateIndex(
name: "IX_Orders_ClientID",
table: "Orders",
column: "ClientID");
migrationBuilder.CreateIndex(
name: "IX_Paymeants_PaymentID",
table: "Paymeants",
column: "PaymentID");
migrationBuilder.CreateIndex(
name: "IX_Products_CostItemID",
table: "Products",
column: "CostItemID");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Messages");
migrationBuilder.DropTable(
name: "OrderProducts");
migrationBuilder.DropTable(
name: "Paymeants");
migrationBuilder.DropTable(
name: "Products");
migrationBuilder.DropTable(
name: "Orders");
migrationBuilder.DropTable(
name: "CostItems");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable(
name: "Employees");
}
}
}