using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace HospitalDataBaseImplements.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Clients", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ClientFIO = table.Column(type: "nvarchar(max)", nullable: false), Email = table.Column(type: "nvarchar(max)", nullable: false), Password = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Clients", x => x.Id); }); migrationBuilder.CreateTable( name: "Illnesses", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), IllnessName = table.Column(type: "nvarchar(max)", nullable: false), Form = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Illnesses", x => x.Id); }); migrationBuilder.CreateTable( name: "Kurse", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Duration = table.Column(type: "nvarchar(max)", nullable: false), CountInDay = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Kurse", x => x.Id); }); migrationBuilder.CreateTable( name: "Symptomses", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), SymptomName = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Symptomses", x => x.Id); }); migrationBuilder.CreateTable( name: "Medicines", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ClientId = table.Column(type: "int", nullable: false), MedicinesName = table.Column(type: "nvarchar(max)", nullable: false), Group = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Medicines", x => x.Id); table.ForeignKey( name: "FK_Medicines_Clients_ClientId", column: x => x.ClientId, principalTable: "Clients", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Procedures", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ClientId = table.Column(type: "int", nullable: false), ProceduresName = table.Column(type: "nvarchar(max)", nullable: false), Type = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Procedures", x => x.Id); table.ForeignKey( name: "FK_Procedures_Clients_ClientId", column: x => x.ClientId, principalTable: "Clients", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "IllnessKurse", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), IllnessId = table.Column(type: "int", nullable: false), KurseId = table.Column(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: "IllnessSymptomses", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), IllnessId = table.Column(type: "int", nullable: false), SymptomsId = table.Column(type: "int", nullable: false) }, constraints: table => { 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); }); migrationBuilder.CreateTable( name: "Recipes", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Dose = table.Column(type: "nvarchar(max)", nullable: false), Date = table.Column(type: "datetime2", nullable: false), ClientId = table.Column(type: "int", nullable: false), ModeOfApplication = table.Column(type: "nvarchar(max)", nullable: false), SymptomsId = table.Column(type: "int", 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_Symptomses_SymptomsId", column: x => x.SymptomsId, principalTable: "Symptomses", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "KurseMedicines", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), MedicineId = table.Column(type: "int", nullable: false), KurseId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_KurseMedicines", x => x.Id); table.ForeignKey( 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, principalTable: "Medicines", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ProcedureMedicine", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), MedicineId = table.Column(type: "int", nullable: false), ProcedureId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ProcedureMedicine", x => x.Id); table.ForeignKey( name: "FK_ProcedureMedicine_Medicines_MedicineId", column: x => x.MedicineId, principalTable: "Medicines", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ProcedureMedicine_Procedures_ProcedureId", column: x => x.ProcedureId, principalTable: "Procedures", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "RecipesProcedures", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), RecipesId = table.Column(type: "int", nullable: false), ProcedureId = table.Column(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", onDelete: ReferentialAction.Restrict); }); 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_KurseMedicines_KurseId", table: "KurseMedicines", column: "KurseId"); migrationBuilder.CreateIndex( name: "IX_KurseMedicines_MedicineId", table: "KurseMedicines", column: "MedicineId"); migrationBuilder.CreateIndex( name: "IX_Medicines_ClientId", table: "Medicines", column: "ClientId"); migrationBuilder.CreateIndex( name: "IX_ProcedureMedicine_MedicineId", table: "ProcedureMedicine", column: "MedicineId"); migrationBuilder.CreateIndex( name: "IX_ProcedureMedicine_ProcedureId", table: "ProcedureMedicine", column: "ProcedureId"); migrationBuilder.CreateIndex( name: "IX_Procedures_ClientId", table: "Procedures", column: "ClientId"); migrationBuilder.CreateIndex( name: "IX_Recipes_ClientId", table: "Recipes", column: "ClientId"); migrationBuilder.CreateIndex( name: "IX_Recipes_SymptomsId", table: "Recipes", column: "SymptomsId"); migrationBuilder.CreateIndex( name: "IX_RecipesProcedures_ProcedureId", table: "RecipesProcedures", column: "ProcedureId"); migrationBuilder.CreateIndex( name: "IX_RecipesProcedures_RecipesId", table: "RecipesProcedures", column: "RecipesId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "IllnessKurse"); migrationBuilder.DropTable( name: "IllnessSymptomses"); migrationBuilder.DropTable( name: "KurseMedicines"); migrationBuilder.DropTable( name: "ProcedureMedicine"); migrationBuilder.DropTable( name: "RecipesProcedures"); migrationBuilder.DropTable( name: "Illnesses"); migrationBuilder.DropTable( name: "Kurse"); migrationBuilder.DropTable( name: "Medicines"); migrationBuilder.DropTable( name: "Procedures"); migrationBuilder.DropTable( name: "Recipes"); migrationBuilder.DropTable( name: "Clients"); migrationBuilder.DropTable( name: "Symptomses"); } } }