438 lines
19 KiB
C#
438 lines
19 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace CaseAccountingDataBaseImplement.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Roles",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Roles", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Users",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Login = table.Column<string>(type: "text", nullable: false),
|
|
Password = table.Column<string>(type: "text", nullable: false),
|
|
RoleId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Users_Roles_RoleId",
|
|
column: x => x.RoleId,
|
|
principalTable: "Roles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Contracts",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Service = table.Column<string>(type: "text", nullable: false),
|
|
Coast = table.Column<decimal>(type: "numeric", nullable: false),
|
|
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UserId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Contracts", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Contracts_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Deals",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Subject = table.Column<string>(type: "text", nullable: false),
|
|
Responsibilities = table.Column<string>(type: "text", nullable: false),
|
|
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UserId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Deals", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Deals_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Specializations",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
UserId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Specializations", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Specializations_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DealContracts",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
DealId = table.Column<int>(type: "integer", nullable: false),
|
|
ContractId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_DealContracts", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_DealContracts_Contracts_ContractId",
|
|
column: x => x.ContractId,
|
|
principalTable: "Contracts",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_DealContracts_Deals_DealId",
|
|
column: x => x.DealId,
|
|
principalTable: "Deals",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Cases",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Applicant = table.Column<string>(type: "text", nullable: false),
|
|
Defendant = table.Column<string>(type: "text", nullable: false),
|
|
Annotation = table.Column<string>(type: "text", nullable: false),
|
|
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
SpecializationId = table.Column<int>(type: "integer", nullable: false),
|
|
UserId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Cases", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Cases_Specializations_SpecializationId",
|
|
column: x => x.SpecializationId,
|
|
principalTable: "Specializations",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Cases_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Lawyers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Surname = table.Column<string>(type: "text", nullable: false),
|
|
Patronymic = table.Column<string>(type: "text", nullable: false),
|
|
Experience = table.Column<int>(type: "integer", nullable: false),
|
|
SpecializationId = table.Column<int>(type: "integer", nullable: false),
|
|
UserId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Lawyers", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Lawyers_Specializations_SpecializationId",
|
|
column: x => x.SpecializationId,
|
|
principalTable: "Specializations",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Lawyers_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "CaseDeals",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
CaseId = table.Column<int>(type: "integer", nullable: false),
|
|
DealId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CaseDeals", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_CaseDeals_Cases_CaseId",
|
|
column: x => x.CaseId,
|
|
principalTable: "Cases",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_CaseDeals_Deals_DealId",
|
|
column: x => x.DealId,
|
|
principalTable: "Deals",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Hearings",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Information = table.Column<string>(type: "text", nullable: false),
|
|
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
CaseId = table.Column<int>(type: "integer", nullable: false),
|
|
UserId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Hearings", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Hearings_Cases_CaseId",
|
|
column: x => x.CaseId,
|
|
principalTable: "Cases",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Hearings_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "CaseLawyers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
CaseId = table.Column<int>(type: "integer", nullable: false),
|
|
LawyerId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CaseLawyers", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_CaseLawyers_Cases_CaseId",
|
|
column: x => x.CaseId,
|
|
principalTable: "Cases",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_CaseLawyers_Lawyers_LawyerId",
|
|
column: x => x.LawyerId,
|
|
principalTable: "Lawyers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "LawyerContracts",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
LawyerId = table.Column<int>(type: "integer", nullable: false),
|
|
ContractId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_LawyerContracts", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_LawyerContracts_Contracts_ContractId",
|
|
column: x => x.ContractId,
|
|
principalTable: "Contracts",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_LawyerContracts_Lawyers_LawyerId",
|
|
column: x => x.LawyerId,
|
|
principalTable: "Lawyers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CaseDeals_CaseId",
|
|
table: "CaseDeals",
|
|
column: "CaseId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CaseDeals_DealId",
|
|
table: "CaseDeals",
|
|
column: "DealId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CaseLawyers_CaseId",
|
|
table: "CaseLawyers",
|
|
column: "CaseId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CaseLawyers_LawyerId",
|
|
table: "CaseLawyers",
|
|
column: "LawyerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Cases_SpecializationId",
|
|
table: "Cases",
|
|
column: "SpecializationId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Cases_UserId",
|
|
table: "Cases",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Contracts_UserId",
|
|
table: "Contracts",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DealContracts_ContractId",
|
|
table: "DealContracts",
|
|
column: "ContractId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DealContracts_DealId",
|
|
table: "DealContracts",
|
|
column: "DealId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Deals_UserId",
|
|
table: "Deals",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Hearings_CaseId",
|
|
table: "Hearings",
|
|
column: "CaseId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Hearings_UserId",
|
|
table: "Hearings",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LawyerContracts_ContractId",
|
|
table: "LawyerContracts",
|
|
column: "ContractId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LawyerContracts_LawyerId",
|
|
table: "LawyerContracts",
|
|
column: "LawyerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Lawyers_SpecializationId",
|
|
table: "Lawyers",
|
|
column: "SpecializationId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Lawyers_UserId",
|
|
table: "Lawyers",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Specializations_UserId",
|
|
table: "Specializations",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Users_RoleId",
|
|
table: "Users",
|
|
column: "RoleId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "CaseDeals");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "CaseLawyers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "DealContracts");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Hearings");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "LawyerContracts");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Deals");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Cases");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Contracts");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Lawyers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Specializations");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Users");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Roles");
|
|
}
|
|
}
|
|
}
|