using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace MysqlMigrations.Migrations { /// public partial class InitialMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Campus", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), CodeName = table.Column(type: "TEXT", maxLength: 16, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), FullName = table.Column(type: "TEXT", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Address = table.Column(type: "TEXT", maxLength: 512, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Campus", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Discipline", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column(type: "TEXT", maxLength: 256, nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Discipline", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Professor", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column(type: "TEXT", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), AltName = table.Column(type: "TEXT", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Professor", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "TypeOfOccupation", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), ShortName = table.Column(type: "TEXT", maxLength: 16, nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_TypeOfOccupation", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Faculty", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column(type: "TEXT", maxLength: 256, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), CampusId = table.Column(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); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "LectureHall", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column(type: "TEXT", maxLength: 64, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), CampusId = table.Column(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); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Group", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column(type: "TEXT", maxLength: 64, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), FacultyId = table.Column(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); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Lesson", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), IsEven = table.Column(type: "BIT(1)", nullable: false), DayOfWeek = table.Column(type: "INTEGER", nullable: false), PairNumber = table.Column(type: "INTEGER", nullable: false), IsExcludedWeeks = table.Column(type: "BIT(1)", nullable: true), GroupId = table.Column(type: "INTEGER", nullable: false), DisciplineId = table.Column(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); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "LessonAssociation", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), LinkToMeet = table.Column(type: "TEXT", maxLength: 512, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), TypeOfOccupationId = table.Column(type: "INTEGER", nullable: false), LessonId = table.Column(type: "INTEGER", nullable: false), ProfessorId = table.Column(type: "INTEGER", nullable: true), LectureHallId = table.Column(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); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "SpecificWeek", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), WeekNumber = table.Column(type: "INTEGER", nullable: false), LessonId = table.Column(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); }) .Annotation("MySql:CharSet", "utf8mb4"); 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); } /// 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"); } } }