261 lines
12 KiB
C#
261 lines
12 KiB
C#
|
using System;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
namespace BankDatabaseImplement.Migrations
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
public partial class InitialCreate : Migration
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Clients",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
FirstName = table.Column<string>(type: "text", nullable: false),
|
|||
|
LastName = table.Column<string>(type: "text", nullable: false),
|
|||
|
MiddleName = table.Column<string>(type: "text", nullable: true),
|
|||
|
Address = table.Column<string>(type: "text", nullable: false),
|
|||
|
PhoneNumber = table.Column<string>(type: "text", nullable: false),
|
|||
|
Email = table.Column<string>(type: "text", nullable: false),
|
|||
|
Password = table.Column<string>(type: "text", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Clients", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Employees",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
FirstName = table.Column<string>(type: "text", nullable: false),
|
|||
|
LastName = table.Column<string>(type: "text", nullable: false),
|
|||
|
MiddleName = table.Column<string>(type: "text", nullable: true),
|
|||
|
Post = table.Column<string>(type: "text", nullable: false),
|
|||
|
PhoneNumber = table.Column<string>(type: "text", nullable: false),
|
|||
|
Password = table.Column<string>(type: "text", nullable: false),
|
|||
|
Email = table.Column<string>(type: "text", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Employees", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Purchases",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
ClientId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
DatePurchase = table.Column<DateOnly>(type: "date", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Purchases", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Purchases_Clients_ClientId",
|
|||
|
column: x => x.ClientId,
|
|||
|
principalTable: "Clients",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Costs",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
EmployeeId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
NameOfCost = table.Column<string>(type: "text", nullable: false),
|
|||
|
Price = table.Column<double>(type: "double precision", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Costs", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Costs_Employees_EmployeeId",
|
|||
|
column: x => x.EmployeeId,
|
|||
|
principalTable: "Employees",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Operations",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
EmployeeId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Model = table.Column<string>(type: "text", nullable: false),
|
|||
|
Price = table.Column<double>(type: "double precision", nullable: false),
|
|||
|
Mark = table.Column<string>(type: "text", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Operations", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Operations_Employees_EmployeeId",
|
|||
|
column: x => x.EmployeeId,
|
|||
|
principalTable: "Employees",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "CostByPurchases",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
CostId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
PurchaseId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Count = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_CostByPurchases", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_CostByPurchases_Costs_CostId",
|
|||
|
column: x => x.CostId,
|
|||
|
principalTable: "Costs",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_CostByPurchases_Purchases_PurchaseId",
|
|||
|
column: x => x.PurchaseId,
|
|||
|
principalTable: "Purchases",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "OperationByPurchases",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
OperationId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
PurchaseId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
CountOperations = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_OperationByPurchases", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_OperationByPurchases_Operations_OperationId",
|
|||
|
column: x => x.OperationId,
|
|||
|
principalTable: "Operations",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_OperationByPurchases_Purchases_PurchaseId",
|
|||
|
column: x => x.PurchaseId,
|
|||
|
principalTable: "Purchases",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Payments",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
OperationByPurchaseId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Date = table.Column<DateOnly>(type: "date", nullable: false),
|
|||
|
PaidPrice = table.Column<double>(type: "double precision", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Payments", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Payments_OperationByPurchases_OperationByPurchaseId",
|
|||
|
column: x => x.OperationByPurchaseId,
|
|||
|
principalTable: "OperationByPurchases",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_CostByPurchases_CostId",
|
|||
|
table: "CostByPurchases",
|
|||
|
column: "CostId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_CostByPurchases_PurchaseId",
|
|||
|
table: "CostByPurchases",
|
|||
|
column: "PurchaseId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Costs_EmployeeId",
|
|||
|
table: "Costs",
|
|||
|
column: "EmployeeId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_OperationByPurchases_OperationId",
|
|||
|
table: "OperationByPurchases",
|
|||
|
column: "OperationId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_OperationByPurchases_PurchaseId",
|
|||
|
table: "OperationByPurchases",
|
|||
|
column: "PurchaseId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Operations_EmployeeId",
|
|||
|
table: "Operations",
|
|||
|
column: "EmployeeId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Payments_OperationByPurchaseId",
|
|||
|
table: "Payments",
|
|||
|
column: "OperationByPurchaseId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Purchases_ClientId",
|
|||
|
table: "Purchases",
|
|||
|
column: "ClientId");
|
|||
|
}
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "CostByPurchases");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Payments");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Costs");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "OperationByPurchases");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Operations");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Purchases");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Employees");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Clients");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|