Files
Backend-Api/CompanyManagment.EFCore/Migrations/20241023170707_Loan And Fine Table.cs
2024-10-23 20:58:10 +03:30

91 lines
4.1 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class LoanAndFineTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Fines",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EmployeeId = table.Column<long>(type: "bigint", nullable: false),
WorkshopId = table.Column<long>(type: "bigint", nullable: false),
Title = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: true),
Amount = table.Column<double>(type: "float", nullable: false),
IsActive = table.Column<string>(type: "nvarchar(1)", maxLength: 1, nullable: false),
FineDate = table.Column<DateTime>(type: "datetime2", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Fines", x => x.id);
});
migrationBuilder.CreateTable(
name: "Loan",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EmployeeId = table.Column<long>(type: "bigint", nullable: false),
WorkshopId = table.Column<long>(type: "bigint", nullable: false),
StartDateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
Count = table.Column<string>(type: "nvarchar(3)", maxLength: 3, nullable: true),
Amount = table.Column<double>(type: "float", nullable: false),
AmountPerMonth = table.Column<double>(type: "float", nullable: false),
GetRounded = table.Column<bool>(type: "bit", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Loan", x => x.id);
});
migrationBuilder.CreateTable(
name: "LoanInstallment",
columns: table => new
{
LoanId = table.Column<long>(type: "bigint", nullable: false),
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AmountForMonth = table.Column<double>(type: "float", nullable: false),
Month = table.Column<string>(type: "nvarchar(2)", maxLength: 2, nullable: true),
Year = table.Column<string>(type: "nvarchar(4)", maxLength: 4, nullable: true),
IsActive = table.Column<string>(type: "nvarchar(1)", maxLength: 1, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LoanInstallment", x => new { x.LoanId, x.Id });
table.ForeignKey(
name: "FK_LoanInstallment_Loan_LoanId",
column: x => x.LoanId,
principalTable: "Loan",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Fines");
migrationBuilder.DropTable(
name: "LoanInstallment");
migrationBuilder.DropTable(
name: "Loan");
}
}
}