2023-04-07 16:53:49 +04:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
namespace ComputerShopDatabaseImplement.Migrations
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
2023-04-08 13:46:24 +04:00
|
|
|
|
public partial class newmigration : Migration
|
2023-04-07 16:53:49 +04:00
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
2023-04-08 13:46:24 +04:00
|
|
|
|
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),
|
|
|
|
|
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Clients", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
2023-04-07 16:53:49 +04:00
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Assemblies",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
AssemblyName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
2023-04-08 13:46:24 +04:00
|
|
|
|
Price = table.Column<double>(type: "float", nullable: false),
|
|
|
|
|
ClientId = table.Column<int>(type: "int", nullable: true)
|
2023-04-07 16:53:49 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Assemblies", x => x.Id);
|
2023-04-08 13:46:24 +04:00
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Assemblies_Clients_ClientId",
|
|
|
|
|
column: x => x.ClientId,
|
|
|
|
|
principalTable: "Clients",
|
|
|
|
|
principalColumn: "Id");
|
2023-04-07 16:53:49 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Components",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
2023-04-08 13:46:24 +04:00
|
|
|
|
Cost = table.Column<double>(type: "float", nullable: false),
|
|
|
|
|
ClientId = table.Column<int>(type: "int", nullable: false)
|
2023-04-07 16:53:49 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Components", x => x.Id);
|
2023-04-08 13:46:24 +04:00
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Components_Clients_ClientId",
|
|
|
|
|
column: x => x.ClientId,
|
|
|
|
|
principalTable: "Clients",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
2023-04-07 16:53:49 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Orders",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
Sum = table.Column<double>(type: "float", nullable: false),
|
|
|
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
2023-04-08 13:46:24 +04:00
|
|
|
|
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
|
|
|
ClientId = table.Column<int>(type: "int", nullable: true)
|
2023-04-07 16:53:49 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Orders", x => x.Id);
|
2023-04-08 13:46:24 +04:00
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Orders_Clients_ClientId",
|
|
|
|
|
column: x => x.ClientId,
|
|
|
|
|
principalTable: "Clients",
|
|
|
|
|
principalColumn: "Id");
|
2023-04-07 16:53:49 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Supplies",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
|
|
|
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
|
|
|
OrderId = table.Column<int>(type: "int", nullable: false),
|
2023-04-08 13:46:24 +04:00
|
|
|
|
ReceivingId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
ClientId = table.Column<int>(type: "int", nullable: true)
|
2023-04-07 16:53:49 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Supplies", x => x.Id);
|
2023-04-08 13:46:24 +04:00
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Supplies_Clients_ClientId",
|
|
|
|
|
column: x => x.ClientId,
|
|
|
|
|
principalTable: "Clients",
|
|
|
|
|
principalColumn: "Id");
|
2023-04-07 16:53:49 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "AssemblyComponents",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
AssemblyId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
ComponentId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
Count = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_AssemblyComponents", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_AssemblyComponents_Assemblies_AssemblyId",
|
|
|
|
|
column: x => x.AssemblyId,
|
|
|
|
|
principalTable: "Assemblies",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_AssemblyComponents_Components_ComponentId",
|
|
|
|
|
column: x => x.ComponentId,
|
|
|
|
|
principalTable: "Components",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Purchases",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
ComponentId = table.Column<int>(type: "int", nullable: false),
|
2023-04-08 13:46:24 +04:00
|
|
|
|
ClientId = table.Column<int>(type: "int", nullable: false),
|
2023-04-07 16:53:49 +04:00
|
|
|
|
Count = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
Sum = table.Column<double>(type: "float", nullable: false),
|
|
|
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
|
|
|
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Purchases", x => x.Id);
|
2023-04-08 13:46:24 +04:00
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Purchases_Clients_ClientId",
|
|
|
|
|
column: x => x.ClientId,
|
|
|
|
|
principalTable: "Clients",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.NoAction);
|
2023-04-07 16:53:49 +04:00
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Purchases_Components_ComponentId",
|
|
|
|
|
column: x => x.ComponentId,
|
|
|
|
|
principalTable: "Components",
|
|
|
|
|
principalColumn: "Id",
|
2023-04-08 13:46:24 +04:00
|
|
|
|
onDelete: ReferentialAction.NoAction);
|
2023-04-07 16:53:49 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "AssemblyOrders",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
AssemblyId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
OrderId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
Count = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_AssemblyOrders", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_AssemblyOrders_Assemblies_AssemblyId",
|
|
|
|
|
column: x => x.AssemblyId,
|
|
|
|
|
principalTable: "Assemblies",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_AssemblyOrders_Orders_OrderId",
|
|
|
|
|
column: x => x.OrderId,
|
|
|
|
|
principalTable: "Orders",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "ComponentSupplies",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
SupplyId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
ComponentId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
Count = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_ComponentSupplies", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_ComponentSupplies_Components_ComponentId",
|
|
|
|
|
column: x => x.ComponentId,
|
|
|
|
|
principalTable: "Components",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_ComponentSupplies_Supplies_SupplyId",
|
|
|
|
|
column: x => x.SupplyId,
|
|
|
|
|
principalTable: "Supplies",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "EquipmentReceivings",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
|
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
2023-04-08 13:46:24 +04:00
|
|
|
|
ClientId = table.Column<int>(type: "int", nullable: true),
|
2023-04-07 16:53:49 +04:00
|
|
|
|
SupplyId = table.Column<int>(type: "int", nullable: true)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_EquipmentReceivings", x => x.Id);
|
2023-04-08 13:46:24 +04:00
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_EquipmentReceivings_Clients_ClientId",
|
|
|
|
|
column: x => x.ClientId,
|
|
|
|
|
principalTable: "Clients",
|
|
|
|
|
principalColumn: "Id");
|
2023-04-07 16:53:49 +04:00
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_EquipmentReceivings_Supplies_SupplyId",
|
|
|
|
|
column: x => x.SupplyId,
|
|
|
|
|
principalTable: "Supplies",
|
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "SupplyOrders",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
OrderId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
SupplyId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
Count = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_SupplyOrders", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_SupplyOrders_Orders_OrderId",
|
|
|
|
|
column: x => x.OrderId,
|
|
|
|
|
principalTable: "Orders",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_SupplyOrders_Supplies_SupplyId",
|
|
|
|
|
column: x => x.SupplyId,
|
|
|
|
|
principalTable: "Supplies",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
2023-04-08 13:46:24 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Assemblies_ClientId",
|
|
|
|
|
table: "Assemblies",
|
|
|
|
|
column: "ClientId");
|
|
|
|
|
|
2023-04-07 16:53:49 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_AssemblyComponents_AssemblyId",
|
|
|
|
|
table: "AssemblyComponents",
|
|
|
|
|
column: "AssemblyId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_AssemblyComponents_ComponentId",
|
|
|
|
|
table: "AssemblyComponents",
|
|
|
|
|
column: "ComponentId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_AssemblyOrders_AssemblyId",
|
|
|
|
|
table: "AssemblyOrders",
|
|
|
|
|
column: "AssemblyId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_AssemblyOrders_OrderId",
|
|
|
|
|
table: "AssemblyOrders",
|
|
|
|
|
column: "OrderId");
|
|
|
|
|
|
2023-04-08 13:46:24 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Components_ClientId",
|
|
|
|
|
table: "Components",
|
|
|
|
|
column: "ClientId");
|
|
|
|
|
|
2023-04-07 16:53:49 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_ComponentSupplies_ComponentId",
|
|
|
|
|
table: "ComponentSupplies",
|
|
|
|
|
column: "ComponentId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_ComponentSupplies_SupplyId",
|
|
|
|
|
table: "ComponentSupplies",
|
|
|
|
|
column: "SupplyId");
|
|
|
|
|
|
2023-04-08 13:46:24 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_EquipmentReceivings_ClientId",
|
|
|
|
|
table: "EquipmentReceivings",
|
|
|
|
|
column: "ClientId");
|
|
|
|
|
|
2023-04-07 16:53:49 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_EquipmentReceivings_SupplyId",
|
|
|
|
|
table: "EquipmentReceivings",
|
|
|
|
|
column: "SupplyId");
|
|
|
|
|
|
2023-04-08 13:46:24 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Orders_ClientId",
|
|
|
|
|
table: "Orders",
|
|
|
|
|
column: "ClientId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Purchases_ClientId",
|
|
|
|
|
table: "Purchases",
|
|
|
|
|
column: "ClientId");
|
|
|
|
|
|
2023-04-07 16:53:49 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Purchases_ComponentId",
|
|
|
|
|
table: "Purchases",
|
|
|
|
|
column: "ComponentId");
|
|
|
|
|
|
2023-04-08 13:46:24 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Supplies_ClientId",
|
|
|
|
|
table: "Supplies",
|
|
|
|
|
column: "ClientId");
|
|
|
|
|
|
2023-04-07 16:53:49 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_SupplyOrders_OrderId",
|
|
|
|
|
table: "SupplyOrders",
|
|
|
|
|
column: "OrderId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_SupplyOrders_SupplyId",
|
|
|
|
|
table: "SupplyOrders",
|
|
|
|
|
column: "SupplyId");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "AssemblyComponents");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "AssemblyOrders");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "ComponentSupplies");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "EquipmentReceivings");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Purchases");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "SupplyOrders");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Assemblies");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Components");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Orders");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Supplies");
|
2023-04-08 13:46:24 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Clients");
|
2023-04-07 16:53:49 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|