PIbd-21_Markov_D.P._LawFirm/LawFirm/LawFirmDatabaseImplement/Migrations/20230502163218_lab8.cs

216 lines
9.3 KiB
C#
Raw Normal View History

2023-03-13 19:57:35 +04:00
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace LawFirmDatabaseImplement.Migrations
{
/// <inheritdoc />
2023-05-02 22:25:24 +04:00
public partial class lab8 : Migration
2023-03-13 19:57:35 +04:00
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Blanks",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
BlankName = table.Column<string>(type: "text", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Blanks", x => x.Id);
});
2023-04-11 00:22:09 +04:00
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientFIO = 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);
});
2023-03-13 19:57:35 +04:00
migrationBuilder.CreateTable(
name: "Documents",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DocumentName = table.Column<string>(type: "text", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Documents", x => x.Id);
});
2023-04-11 00:22:09 +04:00
migrationBuilder.CreateTable(
name: "Implementers",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ImplementerFIO = table.Column<string>(type: "text", nullable: false),
Password = table.Column<string>(type: "text", nullable: false),
WorkExperience = table.Column<int>(type: "integer", nullable: false),
Qualification = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Implementers", x => x.Id);
});
2023-04-25 03:04:42 +04:00
migrationBuilder.CreateTable(
name: "Messages",
columns: table => new
{
MessageId = table.Column<string>(type: "text", nullable: false),
ClientId = table.Column<int>(type: "integer", nullable: true),
SenderName = table.Column<string>(type: "text", nullable: false),
DateDelivery = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Subject = table.Column<string>(type: "text", nullable: false),
Body = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Messages", x => x.MessageId);
table.ForeignKey(
name: "FK_Messages_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id");
});
2023-03-13 19:57:35 +04:00
migrationBuilder.CreateTable(
name: "DocumentBlanks",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DocumentId = table.Column<int>(type: "integer", nullable: false),
BlankId = table.Column<int>(type: "integer", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DocumentBlanks", x => x.Id);
table.ForeignKey(
name: "FK_DocumentBlanks_Blanks_BlankId",
column: x => x.BlankId,
principalTable: "Blanks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DocumentBlanks_Documents_DocumentId",
column: x => x.DocumentId,
principalTable: "Documents",
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),
DocumentId = table.Column<int>(type: "integer", nullable: false),
2023-04-11 00:22:09 +04:00
ClientId = table.Column<int>(type: "integer", nullable: false),
2023-03-13 19:57:35 +04:00
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 with time zone", nullable: false),
2023-04-11 00:22:09 +04:00
ImplementerId = table.Column<int>(type: "integer", nullable: true),
2023-03-13 19:57:35 +04:00
DateImplement = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
2023-04-11 00:22:09 +04:00
table.ForeignKey(
name: "FK_Orders_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
2023-03-13 19:57:35 +04:00
table.ForeignKey(
name: "FK_Orders_Documents_DocumentId",
column: x => x.DocumentId,
principalTable: "Documents",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
2023-04-11 00:22:09 +04:00
table.ForeignKey(
name: "FK_Orders_Implementers_ImplementerId",
column: x => x.ImplementerId,
principalTable: "Implementers",
principalColumn: "Id");
2023-03-13 19:57:35 +04:00
});
migrationBuilder.CreateIndex(
name: "IX_DocumentBlanks_BlankId",
table: "DocumentBlanks",
column: "BlankId");
migrationBuilder.CreateIndex(
name: "IX_DocumentBlanks_DocumentId",
table: "DocumentBlanks",
column: "DocumentId");
2023-04-25 03:04:42 +04:00
migrationBuilder.CreateIndex(
name: "IX_Messages_ClientId",
table: "Messages",
column: "ClientId");
2023-04-11 00:22:09 +04:00
migrationBuilder.CreateIndex(
name: "IX_Orders_ClientId",
table: "Orders",
column: "ClientId");
2023-03-13 19:57:35 +04:00
migrationBuilder.CreateIndex(
name: "IX_Orders_DocumentId",
table: "Orders",
column: "DocumentId");
2023-04-11 00:22:09 +04:00
migrationBuilder.CreateIndex(
name: "IX_Orders_ImplementerId",
table: "Orders",
column: "ImplementerId");
2023-03-13 19:57:35 +04:00
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DocumentBlanks");
2023-04-25 03:04:42 +04:00
migrationBuilder.DropTable(
name: "Messages");
2023-03-13 19:57:35 +04:00
migrationBuilder.DropTable(
name: "Orders");
migrationBuilder.DropTable(
name: "Blanks");
2023-04-11 00:22:09 +04:00
migrationBuilder.DropTable(
name: "Clients");
2023-03-13 19:57:35 +04:00
migrationBuilder.DropTable(
name: "Documents");
2023-04-11 00:22:09 +04:00
migrationBuilder.DropTable(
name: "Implementers");
2023-03-13 19:57:35 +04:00
}
}
}