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-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
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
|
name: "Kurse",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
MedicinesId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
MedicinesName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
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);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Kurse_Medicines_MedicinesId",
|
|
|
|
|
column: x => x.MedicinesId,
|
|
|
|
|
principalTable: "Medicines",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Recipes",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
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),
|
|
|
|
|
MedicinesId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
ModeOfApplication = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Recipes", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Recipes_Clients_ClientId",
|
|
|
|
|
column: x => x.ClientId,
|
|
|
|
|
principalTable: "Clients",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Recipes_Medicines_MedicinesId",
|
|
|
|
|
column: x => x.MedicinesId,
|
|
|
|
|
principalTable: "Medicines",
|
|
|
|
|
principalColumn: "Id",
|
2023-05-20 06:49:33 +04:00
|
|
|
|
onDelete: ReferentialAction.Restrict);
|
2023-04-07 00:53: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);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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.CreateTable(
|
|
|
|
|
name: "RecipesSymptoms",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
RecipesId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
SymptomsId = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_RecipesSymptoms", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_RecipesSymptoms_Recipes_RecipesId",
|
|
|
|
|
column: x => x.RecipesId,
|
|
|
|
|
principalTable: "Recipes",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_RecipesSymptoms_Symptomses_SymptomsId",
|
|
|
|
|
column: x => x.SymptomsId,
|
|
|
|
|
principalTable: "Symptomses",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
|
name: "IX_Kurse_MedicinesId",
|
|
|
|
|
table: "Kurse",
|
|
|
|
|
column: "MedicinesId");
|
|
|
|
|
|
2023-05-20 06:49:33 +04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Medicines_ClientId",
|
|
|
|
|
table: "Medicines",
|
|
|
|
|
column: "ClientId");
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
|
name: "IX_Recipes_MedicinesId",
|
|
|
|
|
table: "Recipes",
|
|
|
|
|
column: "MedicinesId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_RecipesProcedures_ProcedureId",
|
|
|
|
|
table: "RecipesProcedures",
|
|
|
|
|
column: "ProcedureId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_RecipesProcedures_RecipesId",
|
|
|
|
|
table: "RecipesProcedures",
|
|
|
|
|
column: "RecipesId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_RecipesSymptoms_RecipesId",
|
|
|
|
|
table: "RecipesSymptoms",
|
|
|
|
|
column: "RecipesId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_RecipesSymptoms_SymptomsId",
|
|
|
|
|
table: "RecipesSymptoms",
|
|
|
|
|
column: "SymptomsId");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "IllnessKurse");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "IllnessSymptomses");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "RecipesProcedures");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "RecipesSymptoms");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Kurse");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Illnesses");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Procedures");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Recipes");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Symptomses");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
2023-05-20 06:49:33 +04:00
|
|
|
|
name: "Medicines");
|
2023-04-07 00:53:55 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
2023-05-20 06:49:33 +04:00
|
|
|
|
name: "Clients");
|
2023-04-07 00:53:55 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|