433 lines
19 KiB
C#
433 lines
19 KiB
C#
|
using System;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
namespace ComputerHardwareStoreDatabaseImplement.Migrations
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
public partial class create : Migration
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "StoreKeepers",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
Name = table.Column<string>(type: "text", nullable: false),
|
|||
|
Login = table.Column<string>(type: "text", nullable: false),
|
|||
|
Password = table.Column<string>(type: "text", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_StoreKeepers", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Vendors",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
Name = table.Column<string>(type: "text", nullable: false),
|
|||
|
Login = table.Column<string>(type: "text", nullable: false),
|
|||
|
Password = table.Column<string>(type: "text", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Vendors", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Components",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
Name = table.Column<string>(type: "text", nullable: false),
|
|||
|
Cost = table.Column<double>(type: "double precision", nullable: false),
|
|||
|
StoreKeeperId = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Components", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Components_StoreKeepers_StoreKeeperId",
|
|||
|
column: x => x.StoreKeeperId,
|
|||
|
principalTable: "StoreKeepers",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Products",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
Name = table.Column<string>(type: "text", nullable: false),
|
|||
|
Price = table.Column<double>(type: "double precision", nullable: false),
|
|||
|
StoreKeeperId = table.Column<int>(type: "integer", nullable: true)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Products", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Products_StoreKeepers_StoreKeeperId",
|
|||
|
column: x => x.StoreKeeperId,
|
|||
|
principalTable: "StoreKeepers",
|
|||
|
principalColumn: "Id");
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Builds",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
Name = table.Column<string>(type: "text", nullable: false),
|
|||
|
Price = table.Column<double>(type: "double precision", nullable: false),
|
|||
|
VendorId = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Builds", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Builds_Vendors_VendorId",
|
|||
|
column: x => x.VendorId,
|
|||
|
principalTable: "Vendors",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Purchases",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
VendorId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Cost = table.Column<double>(type: "double precision", nullable: false),
|
|||
|
DateCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|||
|
DateImplement = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Purchases", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Purchases_Vendors_VendorId",
|
|||
|
column: x => x.VendorId,
|
|||
|
principalTable: "Vendors",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Orders",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
Count = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Sum = table.Column<double>(type: "double precision", nullable: false),
|
|||
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|||
|
DateCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|||
|
DateImplement = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
|
|||
|
ProductId = table.Column<int>(type: "integer", nullable: true)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Orders", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Orders_Products_ProductId",
|
|||
|
column: x => x.ProductId,
|
|||
|
principalTable: "Products",
|
|||
|
principalColumn: "Id");
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "ProductComponents",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
ProductId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
ComponentId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Count = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_ProductComponents", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_ProductComponents_Components_ComponentId",
|
|||
|
column: x => x.ComponentId,
|
|||
|
principalTable: "Components",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_ProductComponents_Products_ProductId",
|
|||
|
column: x => x.ProductId,
|
|||
|
principalTable: "Products",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "BuildComponents",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
BuildId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
ComponentId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Count = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_BuildComponents", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_BuildComponents_Builds_BuildId",
|
|||
|
column: x => x.BuildId,
|
|||
|
principalTable: "Builds",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_BuildComponents_Components_ComponentId",
|
|||
|
column: x => x.ComponentId,
|
|||
|
principalTable: "Components",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Comments",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
Date = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|||
|
Text = table.Column<string>(type: "text", nullable: false),
|
|||
|
BuildId = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Comments", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Comments_Builds_BuildId",
|
|||
|
column: x => x.BuildId,
|
|||
|
principalTable: "Builds",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "PurchaseBuilds",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
PurchaseId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
BuildId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Count = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_PurchaseBuilds", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_PurchaseBuilds_Builds_BuildId",
|
|||
|
column: x => x.BuildId,
|
|||
|
principalTable: "Builds",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_PurchaseBuilds_Purchases_PurchaseId",
|
|||
|
column: x => x.PurchaseId,
|
|||
|
principalTable: "Purchases",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "PurchaseProducts",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
PurchaseId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
ProductId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Count = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_PurchaseProducts", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_PurchaseProducts_Products_ProductId",
|
|||
|
column: x => x.ProductId,
|
|||
|
principalTable: "Products",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_PurchaseProducts_Purchases_PurchaseId",
|
|||
|
column: x => x.PurchaseId,
|
|||
|
principalTable: "Purchases",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "OrderProducts",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
OrderId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
ProductId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Count = table.Column<int>(type: "integer", 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_BuildComponents_BuildId",
|
|||
|
table: "BuildComponents",
|
|||
|
column: "BuildId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_BuildComponents_ComponentId",
|
|||
|
table: "BuildComponents",
|
|||
|
column: "ComponentId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Builds_VendorId",
|
|||
|
table: "Builds",
|
|||
|
column: "VendorId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Comments_BuildId",
|
|||
|
table: "Comments",
|
|||
|
column: "BuildId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Components_StoreKeeperId",
|
|||
|
table: "Components",
|
|||
|
column: "StoreKeeperId");
|
|||
|
|
|||
|
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_ProductId",
|
|||
|
table: "Orders",
|
|||
|
column: "ProductId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_ProductComponents_ComponentId",
|
|||
|
table: "ProductComponents",
|
|||
|
column: "ComponentId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_ProductComponents_ProductId",
|
|||
|
table: "ProductComponents",
|
|||
|
column: "ProductId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Products_StoreKeeperId",
|
|||
|
table: "Products",
|
|||
|
column: "StoreKeeperId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_PurchaseBuilds_BuildId",
|
|||
|
table: "PurchaseBuilds",
|
|||
|
column: "BuildId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_PurchaseBuilds_PurchaseId",
|
|||
|
table: "PurchaseBuilds",
|
|||
|
column: "PurchaseId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_PurchaseProducts_ProductId",
|
|||
|
table: "PurchaseProducts",
|
|||
|
column: "ProductId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_PurchaseProducts_PurchaseId",
|
|||
|
table: "PurchaseProducts",
|
|||
|
column: "PurchaseId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Purchases_VendorId",
|
|||
|
table: "Purchases",
|
|||
|
column: "VendorId");
|
|||
|
}
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "BuildComponents");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Comments");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "OrderProducts");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "ProductComponents");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "PurchaseBuilds");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "PurchaseProducts");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Orders");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Components");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Builds");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Purchases");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Products");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Vendors");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "StoreKeepers");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|