2023-04-07 00:53:55 +04:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
namespace HospitalDataBaseImplements.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: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Clients", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Illnesses",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
IllnessName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Form = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Illnesses", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
2023-06-20 18:43:55 +04:00
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Kurse",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
Duration = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
CountInDay = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Kurse", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
2023-05-20 06:49:33 +04:00
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Symptomses",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
SymptomName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Symptomses", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
2023-04-07 00:53:55 +04:00
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Medicines",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
2023-05-20 06:49:33 +04:00
|
|
|
|
ClientId = table.Column<int>(type: "int", nullable: false),
|
2023-04-07 00:53:55 +04:00
|
|
|
|
MedicinesName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Group = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Medicines", x => x.Id);
|
2023-05-20 06:49:33 +04:00
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Medicines_Clients_ClientId",
|
|
|
|
|
column: x => x.ClientId,
|
|
|
|
|
principalTable: "Clients",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
2023-04-07 00:53:55 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Procedures",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
2023-05-20 06:49:33 +04:00
|
|
|
|
ClientId = table.Column<int>(type: "int", nullable: false),
|
2023-04-07 00:53:55 +04:00
|
|
|
|
ProceduresName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Type = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Procedures", x => x.Id);
|
2023-05-20 06:49:33 +04:00
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Procedures_Clients_ClientId",
|
|
|
|
|
column: x => x.ClientId,
|
|
|
|
|
principalTable: "Clients",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
2023-04-07 00:53:55 +04:00
|
|
|
|
});
|
|
|
|
|
|
2023-06-20 18:43:55 +04:00
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "IllnessKurse",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
IllnessId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
KurseId = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_IllnessKurse", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_IllnessKurse_Illnesses_IllnessId",
|
|
|
|
|
column: x => x.IllnessId,
|
|
|
|
|
principalTable: "Illnesses",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_IllnessKurse_Kurse_KurseId",
|
|
|
|
|
column: x => x.KurseId,
|
|
|
|
|
principalTable: "Kurse",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
2023-04-07 00:53:55 +04:00
|
|
|
|
migrationBuilder.CreateTable(
|
2023-05-20 06:49:33 +04:00
|
|
|
|
name: "IllnessSymptomses",
|
2023-04-07 00:53:55 +04:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
2023-05-20 06:49:33 +04:00
|
|
|
|
IllnessId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
SymptomsId = table.Column<int>(type: "int", nullable: false)
|
2023-04-07 00:53:55 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2023-05-20 06:49:33 +04:00
|
|
|
|
table.PrimaryKey("PK_IllnessSymptomses", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_IllnessSymptomses_Illnesses_IllnessId",
|
|
|
|
|
column: x => x.IllnessId,
|
|
|
|
|
principalTable: "Illnesses",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_IllnessSymptomses_Symptomses_SymptomsId",
|
|
|
|
|
column: x => x.SymptomsId,
|
|
|
|
|
principalTable: "Symptomses",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
2023-04-07 00:53:55 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
2023-06-03 15:50:25 +04:00
|
|
|
|
name: "Recipes",
|
2023-04-07 00:53:55 +04:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
2023-06-03 15:50:25 +04:00
|
|
|
|
Dose = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
|
|
|
ClientId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
ModeOfApplication = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
SymptomsId = table.Column<int>(type: "int", nullable: false)
|
2023-04-07 00:53:55 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2023-06-03 15:50:25 +04:00
|
|
|
|
table.PrimaryKey("PK_Recipes", x => x.Id);
|
2023-04-07 00:53:55 +04:00
|
|
|
|
table.ForeignKey(
|
2023-06-03 15:50:25 +04:00
|
|
|
|
name: "FK_Recipes_Clients_ClientId",
|
|
|
|
|
column: x => x.ClientId,
|
|
|
|
|
principalTable: "Clients",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Recipes_Symptomses_SymptomsId",
|
|
|
|
|
column: x => x.SymptomsId,
|
|
|
|
|
principalTable: "Symptomses",
|
2023-04-07 00:53:55 +04:00
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
2023-06-20 18:43:55 +04:00
|
|
|
|
name: "KurseMedicines",
|
2023-04-07 00:53:55 +04:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
2023-06-20 18:43:55 +04:00
|
|
|
|
MedicineId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
KurseId = table.Column<int>(type: "int", nullable: false)
|
2023-04-07 00:53:55 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2023-06-20 18:43:55 +04:00
|
|
|
|
table.PrimaryKey("PK_KurseMedicines", x => x.Id);
|
2023-04-07 00:53:55 +04:00
|
|
|
|
table.ForeignKey(
|
2023-06-20 18:43:55 +04:00
|
|
|
|
name: "FK_KurseMedicines_Kurse_KurseId",
|
|
|
|
|
column: x => x.KurseId,
|
|
|
|
|
principalTable: "Kurse",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_KurseMedicines_Medicines_MedicineId",
|
|
|
|
|
column: x => x.MedicineId,
|
2023-04-07 00:53:55 +04:00
|
|
|
|
principalTable: "Medicines",
|
|
|
|
|
principalColumn: "Id",
|
2023-06-03 15:50:25 +04:00
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
2023-04-07 00:53:55 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
2023-06-03 15:50:25 +04:00
|
|
|
|
name: "ProcedureMedicine",
|
2023-04-07 00:53:55 +04:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
2023-06-03 15:50:25 +04:00
|
|
|
|
MedicineId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
ProcedureId = table.Column<int>(type: "int", nullable: false)
|
2023-04-07 00:53:55 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2023-06-03 15:50:25 +04:00
|
|
|
|
table.PrimaryKey("PK_ProcedureMedicine", x => x.Id);
|
2023-04-07 00:53:55 +04:00
|
|
|
|
table.ForeignKey(
|
2023-06-03 15:50:25 +04:00
|
|
|
|
name: "FK_ProcedureMedicine_Medicines_MedicineId",
|
|
|
|
|
column: x => x.MedicineId,
|
|
|
|
|
principalTable: "Medicines",
|
2023-04-07 00:53:55 +04:00
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
2023-06-03 15:50:25 +04:00
|
|
|
|
name: "FK_ProcedureMedicine_Procedures_ProcedureId",
|
|
|
|
|
column: x => x.ProcedureId,
|
|
|
|
|
principalTable: "Procedures",
|
2023-04-07 00:53:55 +04:00
|
|
|
|
principalColumn: "Id",
|
2023-06-03 15:50:25 +04:00
|
|
|
|
onDelete: ReferentialAction.Restrict);
|
2023-04-07 00:53:55 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "RecipesProcedures",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
RecipesId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
ProcedureId = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_RecipesProcedures", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_RecipesProcedures_Procedures_ProcedureId",
|
|
|
|
|
column: x => x.ProcedureId,
|
|
|
|
|
principalTable: "Procedures",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_RecipesProcedures_Recipes_RecipesId",
|
|
|
|
|
column: x => x.RecipesId,
|
|
|
|
|
principalTable: "Recipes",
|
|
|
|
|
principalColumn: "Id",
|
2023-05-20 06:49:33 +04:00
|
|
|
|
onDelete: ReferentialAction.Restrict);
|
2023-04-07 00:53:55 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_IllnessKurse_IllnessId",
|
|
|
|
|
table: "IllnessKurse",
|
|
|
|
|
column: "IllnessId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_IllnessKurse_KurseId",
|
|
|
|
|
table: "IllnessKurse",
|
|
|
|
|
column: "KurseId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_IllnessSymptomses_IllnessId",
|
|
|
|
|
table: "IllnessSymptomses",
|
|
|
|
|
column: "IllnessId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_IllnessSymptomses_SymptomsId",
|
|
|
|
|
table: "IllnessSymptomses",
|
|
|
|
|
column: "SymptomsId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
2023-06-20 18:43:55 +04:00
|
|
|
|
name: "IX_KurseMedicines_KurseId",
|
|
|
|
|
table: "KurseMedicines",
|
|
|
|
|
column: "KurseId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_KurseMedicines_MedicineId",
|
|
|
|
|
table: "KurseMedicines",
|
|
|
|
|
column: "MedicineId");
|
2023-04-07 00:53:55 +04:00
|
|
|
|
|
2023-05-20 06:49:33 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Medicines_ClientId",
|
|
|
|
|
table: "Medicines",
|
|
|
|
|
column: "ClientId");
|
|
|
|
|
|
2023-06-03 15:50:25 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_ProcedureMedicine_MedicineId",
|
|
|
|
|
table: "ProcedureMedicine",
|
|
|
|
|
column: "MedicineId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_ProcedureMedicine_ProcedureId",
|
|
|
|
|
table: "ProcedureMedicine",
|
|
|
|
|
column: "ProcedureId");
|
|
|
|
|
|
2023-05-20 06:49:33 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Procedures_ClientId",
|
|
|
|
|
table: "Procedures",
|
|
|
|
|
column: "ClientId");
|
|
|
|
|
|
2023-04-07 00:53:55 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Recipes_ClientId",
|
|
|
|
|
table: "Recipes",
|
|
|
|
|
column: "ClientId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
2023-06-03 15:50:25 +04:00
|
|
|
|
name: "IX_Recipes_SymptomsId",
|
2023-04-07 00:53:55 +04:00
|
|
|
|
table: "Recipes",
|
2023-06-03 15:50:25 +04:00
|
|
|
|
column: "SymptomsId");
|
2023-04-07 00:53:55 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_RecipesProcedures_ProcedureId",
|
|
|
|
|
table: "RecipesProcedures",
|
|
|
|
|
column: "ProcedureId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_RecipesProcedures_RecipesId",
|
|
|
|
|
table: "RecipesProcedures",
|
|
|
|
|
column: "RecipesId");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "IllnessKurse");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "IllnessSymptomses");
|
|
|
|
|
|
2023-06-20 18:43:55 +04:00
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "KurseMedicines");
|
|
|
|
|
|
2023-04-07 00:53:55 +04:00
|
|
|
|
migrationBuilder.DropTable(
|
2023-06-03 15:50:25 +04:00
|
|
|
|
name: "ProcedureMedicine");
|
2023-04-07 00:53:55 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
2023-06-03 15:50:25 +04:00
|
|
|
|
name: "RecipesProcedures");
|
2023-04-07 00:53:55 +04:00
|
|
|
|
|
2023-06-20 18:43:55 +04:00
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Illnesses");
|
|
|
|
|
|
2023-04-07 00:53:55 +04:00
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Kurse");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
2023-06-20 18:43:55 +04:00
|
|
|
|
name: "Medicines");
|
2023-04-07 00:53:55 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Procedures");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Recipes");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
2023-06-20 18:43:55 +04:00
|
|
|
|
name: "Clients");
|
2023-04-07 00:53:55 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
2023-06-03 15:50:25 +04:00
|
|
|
|
name: "Symptomses");
|
2023-04-07 00:53:55 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|