313 lines
13 KiB
C#
313 lines
13 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace UniversityDatabaseImplement.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Initial : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Storekeepers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
MiddleName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Email = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Storekeepers", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Workers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
MiddleName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Email = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Workers", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Teachers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
StorekeeperId = table.Column<int>(type: "int", nullable: false),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
AcademicDegree = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Position = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Teachers", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Teachers_Storekeepers_StorekeeperId",
|
|
column: x => x.StorekeeperId,
|
|
principalTable: "Storekeepers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PlanOfStudys",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
WorkerId = table.Column<int>(type: "int", nullable: false),
|
|
Profile = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
FormOfStudy = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PlanOfStudys", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_PlanOfStudys_Workers_WorkerId",
|
|
column: x => x.WorkerId,
|
|
principalTable: "Workers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Disciplines",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
TeacherId = table.Column<int>(type: "int", nullable: false),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Disciplines", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Disciplines_Teachers_TeacherId",
|
|
column: x => x.TeacherId,
|
|
principalTable: "Teachers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Statements",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
TeacherId = table.Column<int>(type: "int", nullable: false),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Date = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Statements", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Statements_Teachers_TeacherId",
|
|
column: x => x.TeacherId,
|
|
principalTable: "Teachers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PlanOfStudyTeachers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
PlanOfStudyId = table.Column<int>(type: "int", nullable: false),
|
|
TeacherId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PlanOfStudyTeachers", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_PlanOfStudyTeachers_PlanOfStudys_PlanOfStudyId",
|
|
column: x => x.PlanOfStudyId,
|
|
principalTable: "PlanOfStudys",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_PlanOfStudyTeachers_Teachers_TeacherId",
|
|
column: x => x.TeacherId,
|
|
principalTable: "Teachers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Students",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
PlanOfStudyId = table.Column<int>(type: "int", nullable: false),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Students", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Students_PlanOfStudys_PlanOfStudyId",
|
|
column: x => x.PlanOfStudyId,
|
|
principalTable: "PlanOfStudys",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Attestations",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
StudentId = table.Column<int>(type: "int", nullable: false),
|
|
FormOfEvaluation = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Score = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Attestations", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Attestations_Students_StudentId",
|
|
column: x => x.StudentId,
|
|
principalTable: "Students",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "StudentDisciplines",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
StudentId = table.Column<int>(type: "int", nullable: false),
|
|
DisciplineId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_StudentDisciplines", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_StudentDisciplines_Disciplines_DisciplineId",
|
|
column: x => x.DisciplineId,
|
|
principalTable: "Disciplines",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_StudentDisciplines_Students_StudentId",
|
|
column: x => x.StudentId,
|
|
principalTable: "Students",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Attestations_StudentId",
|
|
table: "Attestations",
|
|
column: "StudentId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Disciplines_TeacherId",
|
|
table: "Disciplines",
|
|
column: "TeacherId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PlanOfStudys_WorkerId",
|
|
table: "PlanOfStudys",
|
|
column: "WorkerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PlanOfStudyTeachers_PlanOfStudyId",
|
|
table: "PlanOfStudyTeachers",
|
|
column: "PlanOfStudyId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PlanOfStudyTeachers_TeacherId",
|
|
table: "PlanOfStudyTeachers",
|
|
column: "TeacherId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Statements_TeacherId",
|
|
table: "Statements",
|
|
column: "TeacherId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_StudentDisciplines_DisciplineId",
|
|
table: "StudentDisciplines",
|
|
column: "DisciplineId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_StudentDisciplines_StudentId",
|
|
table: "StudentDisciplines",
|
|
column: "StudentId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Students_PlanOfStudyId",
|
|
table: "Students",
|
|
column: "PlanOfStudyId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Teachers_StorekeeperId",
|
|
table: "Teachers",
|
|
column: "StorekeeperId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Attestations");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PlanOfStudyTeachers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Statements");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "StudentDisciplines");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Disciplines");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Students");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Teachers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PlanOfStudys");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Storekeepers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Workers");
|
|
}
|
|
}
|
|
}
|