2024-05-25 17:47:14 +04:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
namespace ElectronicsShopDataBaseImplement.Migrations
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
2024-05-31 19:49:56 +04:00
|
|
|
|
public partial class Init : Migration
|
2024-05-25 17:47:14 +04:00
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Clients",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
ID = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Email = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Clients", x => x.ID);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
2024-05-29 15:31:22 +04:00
|
|
|
|
name: "Employees",
|
2024-05-25 17:47:14 +04:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
ID = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
2024-05-29 15:31:22 +04:00
|
|
|
|
EmployeeFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
2024-05-25 17:47:14 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2024-05-29 15:31:22 +04:00
|
|
|
|
table.PrimaryKey("PK_Employees", x => x.ID);
|
2024-05-25 17:47:14 +04:00
|
|
|
|
});
|
|
|
|
|
|
2024-05-31 16:05:43 +04:00
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Messages",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
MessageID = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
|
|
|
ClientID = table.Column<int>(type: "int", nullable: true),
|
|
|
|
|
SenderName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
DateDelivery = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
|
|
|
Subject = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Body = table.Column<string>(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");
|
|
|
|
|
});
|
|
|
|
|
|
2024-05-25 17:47:14 +04:00
|
|
|
|
migrationBuilder.CreateTable(
|
2024-05-29 15:31:22 +04:00
|
|
|
|
name: "Orders",
|
2024-05-25 17:47:14 +04:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
ID = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
2024-05-29 15:31:22 +04:00
|
|
|
|
Sum = table.Column<double>(type: "float", nullable: false),
|
|
|
|
|
ClientID = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
2024-05-25 17:47:14 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2024-05-29 15:31:22 +04:00
|
|
|
|
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);
|
2024-05-25 17:47:14 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
2024-05-29 15:31:22 +04:00
|
|
|
|
name: "CostItems",
|
2024-05-25 17:47:14 +04:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
ID = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
2024-05-29 15:31:22 +04:00
|
|
|
|
EmployeeID = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
2024-05-27 19:12:19 +04:00
|
|
|
|
Price = table.Column<double>(type: "float", nullable: false),
|
2024-05-29 15:31:22 +04:00
|
|
|
|
CostNum = table.Column<int>(type: "int", nullable: false)
|
2024-05-25 17:47:14 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2024-05-29 15:31:22 +04:00
|
|
|
|
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);
|
2024-05-25 17:47:14 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
2024-05-29 15:31:22 +04:00
|
|
|
|
name: "Paymeants",
|
2024-05-25 17:47:14 +04:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
ID = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
2024-05-29 15:31:22 +04:00
|
|
|
|
ProductID = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
OrderID = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
SumPayment = table.Column<double>(type: "float", nullable: false),
|
|
|
|
|
PayOption = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
PaymentID = table.Column<int>(type: "int", nullable: true)
|
2024-05-25 17:47:14 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2024-05-29 15:31:22 +04:00
|
|
|
|
table.PrimaryKey("PK_Paymeants", x => x.ID);
|
2024-05-27 19:12:19 +04:00
|
|
|
|
table.ForeignKey(
|
2024-05-29 15:31:22 +04:00
|
|
|
|
name: "FK_Paymeants_Orders_PaymentID",
|
|
|
|
|
column: x => x.PaymentID,
|
|
|
|
|
principalTable: "Orders",
|
|
|
|
|
principalColumn: "ID");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Products",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
ID = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
ProductName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Price = table.Column<double>(type: "float", nullable: false),
|
|
|
|
|
CostItemID = table.Column<int>(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",
|
2024-05-27 19:12:19 +04:00
|
|
|
|
principalColumn: "ID",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
2024-05-25 17:47:14 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "OrderProducts",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
2024-05-27 19:12:19 +04:00
|
|
|
|
OrderID = table.Column<int>(type: "int", nullable: false),
|
2024-05-25 17:47:14 +04:00
|
|
|
|
ProductID = table.Column<int>(type: "int", nullable: false),
|
2024-05-31 16:05:43 +04:00
|
|
|
|
Count = table.Column<int>(type: "int", nullable: false)
|
2024-05-25 17:47:14 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_OrderProducts", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
2024-05-31 16:05:43 +04:00
|
|
|
|
name: "FK_OrderProducts_Orders_OrderID",
|
|
|
|
|
column: x => x.OrderID,
|
2024-05-25 17:47:14 +04:00
|
|
|
|
principalTable: "Orders",
|
|
|
|
|
principalColumn: "ID",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
2024-05-31 16:05:43 +04:00
|
|
|
|
name: "FK_OrderProducts_Products_ProductID",
|
|
|
|
|
column: x => x.ProductID,
|
2024-05-25 17:47:14 +04:00
|
|
|
|
principalTable: "Products",
|
2024-05-31 16:05:43 +04:00
|
|
|
|
principalColumn: "ID",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
2024-05-27 19:12:19 +04:00
|
|
|
|
});
|
|
|
|
|
|
2024-05-29 15:31:22 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_CostItems_EmployeeID",
|
|
|
|
|
table: "CostItems",
|
|
|
|
|
column: "EmployeeID");
|
2024-05-25 17:47:14 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
2024-05-31 16:05:43 +04:00
|
|
|
|
name: "IX_Messages_ClientID",
|
|
|
|
|
table: "Messages",
|
|
|
|
|
column: "ClientID");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_OrderProducts_OrderID",
|
2024-05-25 17:47:14 +04:00
|
|
|
|
table: "OrderProducts",
|
2024-05-31 16:05:43 +04:00
|
|
|
|
column: "OrderID");
|
2024-05-25 17:47:14 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_OrderProducts_ProductID",
|
|
|
|
|
table: "OrderProducts",
|
|
|
|
|
column: "ProductID");
|
2024-05-27 19:12:19 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Orders_ClientID",
|
|
|
|
|
table: "Orders",
|
|
|
|
|
column: "ClientID");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Paymeants_PaymentID",
|
|
|
|
|
table: "Paymeants",
|
|
|
|
|
column: "PaymentID");
|
2024-05-29 15:31:22 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Products_CostItemID",
|
|
|
|
|
table: "Products",
|
|
|
|
|
column: "CostItemID");
|
2024-05-25 17:47:14 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
2024-05-31 16:05:43 +04:00
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Messages");
|
|
|
|
|
|
2024-05-25 17:47:14 +04:00
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "OrderProducts");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
2024-05-27 19:12:19 +04:00
|
|
|
|
name: "Paymeants");
|
2024-05-25 17:47:14 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Products");
|
2024-05-27 19:12:19 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Orders");
|
|
|
|
|
|
2024-05-29 15:31:22 +04:00
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "CostItems");
|
|
|
|
|
|
2024-05-27 19:12:19 +04:00
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Clients");
|
2024-05-29 15:31:22 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Employees");
|
2024-05-25 17:47:14 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|