366 lines
15 KiB
C#
366 lines
15 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace PsqlMigrations.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitialMigration : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Campus",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
CodeName = table.Column<string>(type: "TEXT", maxLength: 16, nullable: false),
|
|
FullName = table.Column<string>(type: "TEXT", maxLength: 256, nullable: true),
|
|
Address = table.Column<string>(type: "TEXT", maxLength: 512, nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Campus", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Discipline",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Discipline", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Professor",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "TEXT", nullable: false),
|
|
AltName = table.Column<string>(type: "TEXT", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Professor", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "TypeOfOccupation",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
ShortName = table.Column<string>(type: "TEXT", maxLength: 16, nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_TypeOfOccupation", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Faculty",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
|
|
CampusId = table.Column<int>(type: "INTEGER", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Faculty", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Faculty_Campus_CampusId",
|
|
column: x => x.CampusId,
|
|
principalTable: "Campus",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "LectureHall",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
|
|
CampusId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_LectureHall", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_LectureHall_Campus_CampusId",
|
|
column: x => x.CampusId,
|
|
principalTable: "Campus",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Group",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
|
|
FacultyId = table.Column<int>(type: "INTEGER", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Group", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Group_Faculty_FacultyId",
|
|
column: x => x.FacultyId,
|
|
principalTable: "Faculty",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Lesson",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
IsEven = table.Column<bool>(type: "BOOLEAN", nullable: false),
|
|
DayOfWeek = table.Column<int>(type: "INTEGER", nullable: false),
|
|
PairNumber = table.Column<int>(type: "INTEGER", nullable: false),
|
|
IsExcludedWeeks = table.Column<bool>(type: "BOOLEAN", nullable: true),
|
|
GroupId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
DisciplineId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Lesson", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Lesson_Discipline_DisciplineId",
|
|
column: x => x.DisciplineId,
|
|
principalTable: "Discipline",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Lesson_Group_GroupId",
|
|
column: x => x.GroupId,
|
|
principalTable: "Group",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "LessonAssociation",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
LinkToMeet = table.Column<string>(type: "TEXT", maxLength: 512, nullable: true),
|
|
TypeOfOccupationId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
LessonId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
ProfessorId = table.Column<int>(type: "INTEGER", nullable: true),
|
|
LectureHallId = table.Column<int>(type: "INTEGER", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_LessonAssociation", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_LessonAssociation_LectureHall_LectureHallId",
|
|
column: x => x.LectureHallId,
|
|
principalTable: "LectureHall",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
table.ForeignKey(
|
|
name: "FK_LessonAssociation_Lesson_LessonId",
|
|
column: x => x.LessonId,
|
|
principalTable: "Lesson",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_LessonAssociation_Professor_ProfessorId",
|
|
column: x => x.ProfessorId,
|
|
principalTable: "Professor",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
table.ForeignKey(
|
|
name: "FK_LessonAssociation_TypeOfOccupation_TypeOfOccupationId",
|
|
column: x => x.TypeOfOccupationId,
|
|
principalTable: "TypeOfOccupation",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SpecificWeek",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
WeekNumber = table.Column<int>(type: "INTEGER", nullable: false),
|
|
LessonId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SpecificWeek", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_SpecificWeek_Lesson_LessonId",
|
|
column: x => x.LessonId,
|
|
principalTable: "Lesson",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Campus_Id",
|
|
table: "Campus",
|
|
column: "Id",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Discipline_Id",
|
|
table: "Discipline",
|
|
column: "Id",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Faculty_CampusId",
|
|
table: "Faculty",
|
|
column: "CampusId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Faculty_Id",
|
|
table: "Faculty",
|
|
column: "Id",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Group_FacultyId",
|
|
table: "Group",
|
|
column: "FacultyId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Group_Id",
|
|
table: "Group",
|
|
column: "Id",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LectureHall_CampusId",
|
|
table: "LectureHall",
|
|
column: "CampusId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LectureHall_Id",
|
|
table: "LectureHall",
|
|
column: "Id",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Lesson_DisciplineId",
|
|
table: "Lesson",
|
|
column: "DisciplineId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Lesson_GroupId",
|
|
table: "Lesson",
|
|
column: "GroupId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Lesson_Id",
|
|
table: "Lesson",
|
|
column: "Id",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LessonAssociation_Id",
|
|
table: "LessonAssociation",
|
|
column: "Id",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LessonAssociation_LectureHallId",
|
|
table: "LessonAssociation",
|
|
column: "LectureHallId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LessonAssociation_LessonId",
|
|
table: "LessonAssociation",
|
|
column: "LessonId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LessonAssociation_ProfessorId",
|
|
table: "LessonAssociation",
|
|
column: "ProfessorId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LessonAssociation_TypeOfOccupationId",
|
|
table: "LessonAssociation",
|
|
column: "TypeOfOccupationId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Professor_Id",
|
|
table: "Professor",
|
|
column: "Id",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SpecificWeek_Id",
|
|
table: "SpecificWeek",
|
|
column: "Id",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SpecificWeek_LessonId",
|
|
table: "SpecificWeek",
|
|
column: "LessonId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_TypeOfOccupation_Id",
|
|
table: "TypeOfOccupation",
|
|
column: "Id",
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "LessonAssociation");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SpecificWeek");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "LectureHall");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Professor");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "TypeOfOccupation");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Lesson");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Discipline");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Group");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Faculty");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Campus");
|
|
}
|
|
}
|
|
}
|