384 lines
16 KiB
C#
384 lines
16 KiB
C#
|
using System;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
namespace BankDatabaseImplement.Migrations
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
public partial class InitialCreate : Migration
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "BankOperators",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
MiddleName = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_BankOperators", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Operators",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
MiddleName = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Operators", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "CreditPrograms",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
Percent = table.Column<float>(type: "real", nullable: false),
|
|||
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
BankOperatorId = table.Column<int>(type: "int", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_CreditPrograms", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_CreditPrograms_BankOperators_BankOperatorId",
|
|||
|
column: x => x.BankOperatorId,
|
|||
|
principalTable: "BankOperators",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Currencies",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
BankOperatorId = table.Column<int>(type: "int", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Currencies", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Currencies_BankOperators_BankOperatorId",
|
|||
|
column: x => x.BankOperatorId,
|
|||
|
principalTable: "BankOperators",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Payments",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
PaymentDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|||
|
OperatorId = table.Column<int>(type: "int", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Payments", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Payments_Operators_OperatorId",
|
|||
|
column: x => x.OperatorId,
|
|||
|
principalTable: "Operators",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Deals",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
ClientId = table.Column<int>(type: "int", nullable: false),
|
|||
|
DealDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|||
|
OperatorId = table.Column<int>(type: "int", nullable: false),
|
|||
|
CreditProgramId = table.Column<int>(type: "int", nullable: true)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Deals", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Deals_CreditPrograms_CreditProgramId",
|
|||
|
column: x => x.CreditProgramId,
|
|||
|
principalTable: "CreditPrograms",
|
|||
|
principalColumn: "Id");
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Deals_Operators_OperatorId",
|
|||
|
column: x => x.OperatorId,
|
|||
|
principalTable: "Operators",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "CreditProgramCurrencies",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
CurrencyId = table.Column<int>(type: "int", nullable: false),
|
|||
|
CreditProgramId = table.Column<int>(type: "int", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_CreditProgramCurrencies", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_CreditProgramCurrencies_CreditPrograms_CreditProgramId",
|
|||
|
column: x => x.CreditProgramId,
|
|||
|
principalTable: "CreditPrograms",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Restrict);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_CreditProgramCurrencies_Currencies_CurrencyId",
|
|||
|
column: x => x.CurrencyId,
|
|||
|
principalTable: "Currencies",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Restrict);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "CurrencyPurchases",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
Amount = table.Column<float>(type: "real", nullable: false),
|
|||
|
PurchaseDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|||
|
BankOperatorId = table.Column<int>(type: "int", nullable: false),
|
|||
|
CurrencyId = table.Column<int>(type: "int", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_CurrencyPurchases", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_CurrencyPurchases_BankOperators_BankOperatorId",
|
|||
|
column: x => x.BankOperatorId,
|
|||
|
principalTable: "BankOperators",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Restrict);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_CurrencyPurchases_Currencies_CurrencyId",
|
|||
|
column: x => x.CurrencyId,
|
|||
|
principalTable: "Currencies",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Restrict);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "CurrencyPayments",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
CurrencyId = table.Column<int>(type: "int", nullable: false),
|
|||
|
PaymentId = table.Column<int>(type: "int", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_CurrencyPayments", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_CurrencyPayments_Currencies_CurrencyId",
|
|||
|
column: x => x.CurrencyId,
|
|||
|
principalTable: "Currencies",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_CurrencyPayments_Payments_PaymentId",
|
|||
|
column: x => x.PaymentId,
|
|||
|
principalTable: "Payments",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Transfers",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
Amount = table.Column<float>(type: "real", nullable: false),
|
|||
|
TransferDateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|||
|
PaymentId = table.Column<int>(type: "int", nullable: false),
|
|||
|
OperatorId = table.Column<int>(type: "int", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Transfers", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Transfers_Operators_OperatorId",
|
|||
|
column: x => x.OperatorId,
|
|||
|
principalTable: "Operators",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Restrict);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Transfers_Payments_PaymentId",
|
|||
|
column: x => x.PaymentId,
|
|||
|
principalTable: "Payments",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Restrict);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "DealPayments",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
DealId = table.Column<int>(type: "int", nullable: false),
|
|||
|
PaymentId = table.Column<int>(type: "int", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_DealPayments", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_DealPayments_Deals_DealId",
|
|||
|
column: x => x.DealId,
|
|||
|
principalTable: "Deals",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.NoAction);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_DealPayments_Payments_PaymentId",
|
|||
|
column: x => x.PaymentId,
|
|||
|
principalTable: "Payments",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.NoAction);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_CreditProgramCurrencies_CreditProgramId",
|
|||
|
table: "CreditProgramCurrencies",
|
|||
|
column: "CreditProgramId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_CreditProgramCurrencies_CurrencyId",
|
|||
|
table: "CreditProgramCurrencies",
|
|||
|
column: "CurrencyId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_CreditPrograms_BankOperatorId",
|
|||
|
table: "CreditPrograms",
|
|||
|
column: "BankOperatorId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Currencies_BankOperatorId",
|
|||
|
table: "Currencies",
|
|||
|
column: "BankOperatorId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_CurrencyPayments_CurrencyId",
|
|||
|
table: "CurrencyPayments",
|
|||
|
column: "CurrencyId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_CurrencyPayments_PaymentId",
|
|||
|
table: "CurrencyPayments",
|
|||
|
column: "PaymentId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_CurrencyPurchases_BankOperatorId",
|
|||
|
table: "CurrencyPurchases",
|
|||
|
column: "BankOperatorId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_CurrencyPurchases_CurrencyId",
|
|||
|
table: "CurrencyPurchases",
|
|||
|
column: "CurrencyId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_DealPayments_DealId",
|
|||
|
table: "DealPayments",
|
|||
|
column: "DealId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_DealPayments_PaymentId",
|
|||
|
table: "DealPayments",
|
|||
|
column: "PaymentId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Deals_CreditProgramId",
|
|||
|
table: "Deals",
|
|||
|
column: "CreditProgramId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Deals_OperatorId",
|
|||
|
table: "Deals",
|
|||
|
column: "OperatorId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Payments_OperatorId",
|
|||
|
table: "Payments",
|
|||
|
column: "OperatorId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Transfers_OperatorId",
|
|||
|
table: "Transfers",
|
|||
|
column: "OperatorId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Transfers_PaymentId",
|
|||
|
table: "Transfers",
|
|||
|
column: "PaymentId");
|
|||
|
}
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "CreditProgramCurrencies");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "CurrencyPayments");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "CurrencyPurchases");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "DealPayments");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Transfers");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Currencies");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Deals");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Payments");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "CreditPrograms");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Operators");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "BankOperators");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|