PIbd-21_CourseWork_Polyclin.../Polyclinic/PolyclinicDatabaseImplement/Migrations/20240430074427_InitializeDatabase.cs

346 lines
14 KiB
C#
Raw Normal View History

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PolyclinicDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitializeDatabase : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Procedures",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Comment = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Procedures", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Recipes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProceduresCount = table.Column<int>(type: "int", nullable: false),
Comment = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Recipes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Symptomes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Comment = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Symptomes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FIO = 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),
Role = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Courses",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DaysCount = table.Column<int>(type: "int", nullable: false),
PillsPerDay = table.Column<int>(type: "int", nullable: false),
Comment = table.Column<string>(type: "nvarchar(max)", nullable: false),
RecipeId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Courses", x => x.Id);
table.ForeignKey(
name: "FK_Courses_Recipes_RecipeId",
column: x => x.RecipeId,
principalTable: "Recipes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ProcedureRecipes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProcedureId = table.Column<int>(type: "int", nullable: false),
RecipeId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProcedureRecipes", x => x.Id);
table.ForeignKey(
name: "FK_ProcedureRecipes_Procedures_ProcedureId",
column: x => x.ProcedureId,
principalTable: "Procedures",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ProcedureRecipes_Recipes_RecipeId",
column: x => x.RecipeId,
principalTable: "Recipes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Medicaments",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Comment = table.Column<string>(type: "nvarchar(max)", nullable: false),
ProcedureId = table.Column<int>(type: "int", nullable: false),
SymptomId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Medicaments", x => x.Id);
table.ForeignKey(
name: "FK_Medicaments_Procedures_ProcedureId",
column: x => x.ProcedureId,
principalTable: "Procedures",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Medicaments_Symptomes_SymptomId",
column: x => x.SymptomId,
principalTable: "Symptomes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "SymptomRecipes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
SymptomId = table.Column<int>(type: "int", nullable: false),
RecipeId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SymptomRecipes", x => x.Id);
table.ForeignKey(
name: "FK_SymptomRecipes_Recipes_RecipeId",
column: x => x.RecipeId,
principalTable: "Recipes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_SymptomRecipes_Symptomes_SymptomId",
column: x => x.SymptomId,
principalTable: "Symptomes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Diagnoses",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Comment = table.Column<string>(type: "nvarchar(max)", nullable: false),
UserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Diagnoses", x => x.Id);
table.ForeignKey(
name: "FK_Diagnoses_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CourseDiagnoses",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CourseId = table.Column<int>(type: "int", nullable: false),
DiagnoseId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CourseDiagnoses", x => x.Id);
table.ForeignKey(
name: "FK_CourseDiagnoses_Courses_CourseId",
column: x => x.CourseId,
principalTable: "Courses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CourseDiagnoses_Diagnoses_DiagnoseId",
column: x => x.DiagnoseId,
principalTable: "Diagnoses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "SymptomDiagnoses",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
SymptomId = table.Column<int>(type: "int", nullable: false),
DiagnoseId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SymptomDiagnoses", x => x.Id);
table.ForeignKey(
name: "FK_SymptomDiagnoses_Diagnoses_DiagnoseId",
column: x => x.DiagnoseId,
principalTable: "Diagnoses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_SymptomDiagnoses_Symptomes_SymptomId",
column: x => x.SymptomId,
principalTable: "Symptomes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_CourseDiagnoses_CourseId",
table: "CourseDiagnoses",
column: "CourseId");
migrationBuilder.CreateIndex(
name: "IX_CourseDiagnoses_DiagnoseId",
table: "CourseDiagnoses",
column: "DiagnoseId");
migrationBuilder.CreateIndex(
name: "IX_Courses_RecipeId",
table: "Courses",
column: "RecipeId");
migrationBuilder.CreateIndex(
name: "IX_Diagnoses_UserId",
table: "Diagnoses",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Medicaments_ProcedureId",
table: "Medicaments",
column: "ProcedureId");
migrationBuilder.CreateIndex(
name: "IX_Medicaments_SymptomId",
table: "Medicaments",
column: "SymptomId");
migrationBuilder.CreateIndex(
name: "IX_ProcedureRecipes_ProcedureId",
table: "ProcedureRecipes",
column: "ProcedureId");
migrationBuilder.CreateIndex(
name: "IX_ProcedureRecipes_RecipeId",
table: "ProcedureRecipes",
column: "RecipeId");
migrationBuilder.CreateIndex(
name: "IX_SymptomDiagnoses_DiagnoseId",
table: "SymptomDiagnoses",
column: "DiagnoseId");
migrationBuilder.CreateIndex(
name: "IX_SymptomDiagnoses_SymptomId",
table: "SymptomDiagnoses",
column: "SymptomId");
migrationBuilder.CreateIndex(
name: "IX_SymptomRecipes_RecipeId",
table: "SymptomRecipes",
column: "RecipeId");
migrationBuilder.CreateIndex(
name: "IX_SymptomRecipes_SymptomId",
table: "SymptomRecipes",
column: "SymptomId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CourseDiagnoses");
migrationBuilder.DropTable(
name: "Medicaments");
migrationBuilder.DropTable(
name: "ProcedureRecipes");
migrationBuilder.DropTable(
name: "SymptomDiagnoses");
migrationBuilder.DropTable(
name: "SymptomRecipes");
migrationBuilder.DropTable(
name: "Courses");
migrationBuilder.DropTable(
name: "Procedures");
migrationBuilder.DropTable(
name: "Diagnoses");
migrationBuilder.DropTable(
name: "Symptomes");
migrationBuilder.DropTable(
name: "Recipes");
migrationBuilder.DropTable(
name: "Users");
}
}
}