From d2ba2d982c60197c902b9099f87928b326b4d30b Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Sat, 1 Jun 2024 05:42:23 +0300 Subject: [PATCH] feat: add migrations --- ...0240601023106_InitialMigration.Designer.cs | 442 ++++++++++++++++++ .../20240601023106_InitialMigration.cs | 389 +++++++++++++++ .../Migrations/UberDbContextModelSnapshot.cs | 439 +++++++++++++++++ ...0240601021702_InitialMigration.Designer.cs | 442 ++++++++++++++++++ .../20240601021702_InitialMigration.cs | 365 +++++++++++++++ .../Migrations/UberDbContextModelSnapshot.cs | 439 +++++++++++++++++ ...0240601015714_InitialMigration.Designer.cs | 417 +++++++++++++++++ .../20240601015714_InitialMigration.cs | 364 +++++++++++++++ .../Migrations/UberDbContextModelSnapshot.cs | 414 ++++++++++++++++ 9 files changed, 3711 insertions(+) create mode 100644 SqlData/Migrations/MysqlMigrations/Migrations/20240601023106_InitialMigration.Designer.cs create mode 100644 SqlData/Migrations/MysqlMigrations/Migrations/20240601023106_InitialMigration.cs create mode 100644 SqlData/Migrations/MysqlMigrations/Migrations/UberDbContextModelSnapshot.cs create mode 100644 SqlData/Migrations/PsqlMigrations/Migrations/20240601021702_InitialMigration.Designer.cs create mode 100644 SqlData/Migrations/PsqlMigrations/Migrations/20240601021702_InitialMigration.cs create mode 100644 SqlData/Migrations/PsqlMigrations/Migrations/UberDbContextModelSnapshot.cs create mode 100644 SqlData/Migrations/SqliteMigrations/Migrations/20240601015714_InitialMigration.Designer.cs create mode 100644 SqlData/Migrations/SqliteMigrations/Migrations/20240601015714_InitialMigration.cs create mode 100644 SqlData/Migrations/SqliteMigrations/Migrations/UberDbContextModelSnapshot.cs diff --git a/SqlData/Migrations/MysqlMigrations/Migrations/20240601023106_InitialMigration.Designer.cs b/SqlData/Migrations/MysqlMigrations/Migrations/20240601023106_InitialMigration.Designer.cs new file mode 100644 index 0000000..d4c0d32 --- /dev/null +++ b/SqlData/Migrations/MysqlMigrations/Migrations/20240601023106_InitialMigration.Designer.cs @@ -0,0 +1,442 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Mirea.Api.DataAccess.Persistence; + +#nullable disable + +namespace MysqlMigrations.Migrations +{ + [DbContext(typeof(UberDbContext))] + [Migration("20240601023106_InitialMigration")] + partial class InitialMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Address") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property("CodeName") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("TEXT"); + + b.Property("FullName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Campus", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Discipline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Discipline", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CampusId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Faculty", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("FacultyId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("FacultyId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Group", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CampusId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("LectureHall", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("DayOfWeek") + .HasColumnType("INTEGER"); + + b.Property("DisciplineId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.Property("IsEven") + .HasColumnType("BIT(1)"); + + b.Property("IsExcludedWeeks") + .HasColumnType("BIT(1)"); + + b.Property("PairNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineId"); + + b.HasIndex("GroupId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Lesson", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LessonAssociation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("LectureHallId") + .HasColumnType("INTEGER"); + + b.Property("LessonId") + .HasColumnType("INTEGER"); + + b.Property("LinkToMeet") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property("ProfessorId") + .HasColumnType("INTEGER"); + + b.Property("TypeOfOccupationId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LectureHallId"); + + b.HasIndex("LessonId"); + + b.HasIndex("ProfessorId"); + + b.HasIndex("TypeOfOccupationId"); + + b.ToTable("LessonAssociation", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Professor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AltName") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Professor", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.SpecificWeek", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("LessonId") + .HasColumnType("INTEGER"); + + b.Property("WeekNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LessonId"); + + b.ToTable("SpecificWeek", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ShortName") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("TypeOfOccupation", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Campus", "Campus") + .WithMany("Faculties") + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Faculty", "Faculty") + .WithMany("Groups") + .HasForeignKey("FacultyId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Faculty"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Campus", "Campus") + .WithMany("LectureHalls") + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Discipline", "Discipline") + .WithMany("Lessons") + .HasForeignKey("DisciplineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Group", "Group") + .WithMany("Lessons") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Discipline"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LessonAssociation", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", "LectureHall") + .WithMany("LessonAssociations") + .HasForeignKey("LectureHallId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Lesson", "Lesson") + .WithMany("LessonAssociations") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Professor", "Professor") + .WithMany("LessonAssociations") + .HasForeignKey("ProfessorId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", "TypeOfOccupation") + .WithMany("Lessons") + .HasForeignKey("TypeOfOccupationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LectureHall"); + + b.Navigation("Lesson"); + + b.Navigation("Professor"); + + b.Navigation("TypeOfOccupation"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.SpecificWeek", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Lesson", "Lesson") + .WithMany("SpecificWeeks") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => + { + b.Navigation("Faculties"); + + b.Navigation("LectureHalls"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Discipline", b => + { + b.Navigation("Lessons"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.Navigation("Groups"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.Navigation("Lessons"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.Navigation("LessonAssociations"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.Navigation("LessonAssociations"); + + b.Navigation("SpecificWeeks"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Professor", b => + { + b.Navigation("LessonAssociations"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", b => + { + b.Navigation("Lessons"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/SqlData/Migrations/MysqlMigrations/Migrations/20240601023106_InitialMigration.cs b/SqlData/Migrations/MysqlMigrations/Migrations/20240601023106_InitialMigration.cs new file mode 100644 index 0000000..573b78f --- /dev/null +++ b/SqlData/Migrations/MysqlMigrations/Migrations/20240601023106_InitialMigration.cs @@ -0,0 +1,389 @@ +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"); + } + } +} diff --git a/SqlData/Migrations/MysqlMigrations/Migrations/UberDbContextModelSnapshot.cs b/SqlData/Migrations/MysqlMigrations/Migrations/UberDbContextModelSnapshot.cs new file mode 100644 index 0000000..5e0b48f --- /dev/null +++ b/SqlData/Migrations/MysqlMigrations/Migrations/UberDbContextModelSnapshot.cs @@ -0,0 +1,439 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Mirea.Api.DataAccess.Persistence; + +#nullable disable + +namespace MysqlMigrations.Migrations +{ + [DbContext(typeof(UberDbContext))] + partial class UberDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Address") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property("CodeName") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("TEXT"); + + b.Property("FullName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Campus", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Discipline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Discipline", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CampusId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Faculty", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("FacultyId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("FacultyId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Group", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CampusId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("LectureHall", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("DayOfWeek") + .HasColumnType("INTEGER"); + + b.Property("DisciplineId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.Property("IsEven") + .HasColumnType("BIT(1)"); + + b.Property("IsExcludedWeeks") + .HasColumnType("BIT(1)"); + + b.Property("PairNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineId"); + + b.HasIndex("GroupId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Lesson", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LessonAssociation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("LectureHallId") + .HasColumnType("INTEGER"); + + b.Property("LessonId") + .HasColumnType("INTEGER"); + + b.Property("LinkToMeet") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property("ProfessorId") + .HasColumnType("INTEGER"); + + b.Property("TypeOfOccupationId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LectureHallId"); + + b.HasIndex("LessonId"); + + b.HasIndex("ProfessorId"); + + b.HasIndex("TypeOfOccupationId"); + + b.ToTable("LessonAssociation", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Professor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AltName") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Professor", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.SpecificWeek", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("LessonId") + .HasColumnType("INTEGER"); + + b.Property("WeekNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LessonId"); + + b.ToTable("SpecificWeek", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ShortName") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("TypeOfOccupation", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Campus", "Campus") + .WithMany("Faculties") + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Faculty", "Faculty") + .WithMany("Groups") + .HasForeignKey("FacultyId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Faculty"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Campus", "Campus") + .WithMany("LectureHalls") + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Discipline", "Discipline") + .WithMany("Lessons") + .HasForeignKey("DisciplineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Group", "Group") + .WithMany("Lessons") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Discipline"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LessonAssociation", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", "LectureHall") + .WithMany("LessonAssociations") + .HasForeignKey("LectureHallId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Lesson", "Lesson") + .WithMany("LessonAssociations") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Professor", "Professor") + .WithMany("LessonAssociations") + .HasForeignKey("ProfessorId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", "TypeOfOccupation") + .WithMany("Lessons") + .HasForeignKey("TypeOfOccupationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LectureHall"); + + b.Navigation("Lesson"); + + b.Navigation("Professor"); + + b.Navigation("TypeOfOccupation"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.SpecificWeek", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Lesson", "Lesson") + .WithMany("SpecificWeeks") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => + { + b.Navigation("Faculties"); + + b.Navigation("LectureHalls"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Discipline", b => + { + b.Navigation("Lessons"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.Navigation("Groups"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.Navigation("Lessons"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.Navigation("LessonAssociations"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.Navigation("LessonAssociations"); + + b.Navigation("SpecificWeeks"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Professor", b => + { + b.Navigation("LessonAssociations"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", b => + { + b.Navigation("Lessons"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/SqlData/Migrations/PsqlMigrations/Migrations/20240601021702_InitialMigration.Designer.cs b/SqlData/Migrations/PsqlMigrations/Migrations/20240601021702_InitialMigration.Designer.cs new file mode 100644 index 0000000..1bea549 --- /dev/null +++ b/SqlData/Migrations/PsqlMigrations/Migrations/20240601021702_InitialMigration.Designer.cs @@ -0,0 +1,442 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Mirea.Api.DataAccess.Persistence; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace PsqlMigrations.Migrations +{ + [DbContext(typeof(UberDbContext))] + [Migration("20240601021702_InitialMigration")] + partial class InitialMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property("CodeName") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("TEXT"); + + b.Property("FullName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Campus", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Discipline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Discipline", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CampusId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Faculty", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FacultyId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("FacultyId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Group", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CampusId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("LectureHall", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DayOfWeek") + .HasColumnType("INTEGER"); + + b.Property("DisciplineId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.Property("IsEven") + .HasColumnType("BOOLEAN"); + + b.Property("IsExcludedWeeks") + .HasColumnType("BOOLEAN"); + + b.Property("PairNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineId"); + + b.HasIndex("GroupId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Lesson", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LessonAssociation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LectureHallId") + .HasColumnType("INTEGER"); + + b.Property("LessonId") + .HasColumnType("INTEGER"); + + b.Property("LinkToMeet") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property("ProfessorId") + .HasColumnType("INTEGER"); + + b.Property("TypeOfOccupationId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LectureHallId"); + + b.HasIndex("LessonId"); + + b.HasIndex("ProfessorId"); + + b.HasIndex("TypeOfOccupationId"); + + b.ToTable("LessonAssociation", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Professor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AltName") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Professor", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.SpecificWeek", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LessonId") + .HasColumnType("INTEGER"); + + b.Property("WeekNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LessonId"); + + b.ToTable("SpecificWeek", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ShortName") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("TypeOfOccupation", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Campus", "Campus") + .WithMany("Faculties") + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Faculty", "Faculty") + .WithMany("Groups") + .HasForeignKey("FacultyId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Faculty"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Campus", "Campus") + .WithMany("LectureHalls") + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Discipline", "Discipline") + .WithMany("Lessons") + .HasForeignKey("DisciplineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Group", "Group") + .WithMany("Lessons") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Discipline"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LessonAssociation", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", "LectureHall") + .WithMany("LessonAssociations") + .HasForeignKey("LectureHallId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Lesson", "Lesson") + .WithMany("LessonAssociations") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Professor", "Professor") + .WithMany("LessonAssociations") + .HasForeignKey("ProfessorId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", "TypeOfOccupation") + .WithMany("Lessons") + .HasForeignKey("TypeOfOccupationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LectureHall"); + + b.Navigation("Lesson"); + + b.Navigation("Professor"); + + b.Navigation("TypeOfOccupation"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.SpecificWeek", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Lesson", "Lesson") + .WithMany("SpecificWeeks") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => + { + b.Navigation("Faculties"); + + b.Navigation("LectureHalls"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Discipline", b => + { + b.Navigation("Lessons"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.Navigation("Groups"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.Navigation("Lessons"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.Navigation("LessonAssociations"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.Navigation("LessonAssociations"); + + b.Navigation("SpecificWeeks"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Professor", b => + { + b.Navigation("LessonAssociations"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", b => + { + b.Navigation("Lessons"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/SqlData/Migrations/PsqlMigrations/Migrations/20240601021702_InitialMigration.cs b/SqlData/Migrations/PsqlMigrations/Migrations/20240601021702_InitialMigration.cs new file mode 100644 index 0000000..9015b9f --- /dev/null +++ b/SqlData/Migrations/PsqlMigrations/Migrations/20240601021702_InitialMigration.cs @@ -0,0 +1,365 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace PsqlMigrations.Migrations +{ + /// + public partial class InitialMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Campus", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CodeName = table.Column(type: "TEXT", maxLength: 16, nullable: false), + FullName = table.Column(type: "TEXT", maxLength: 256, nullable: true), + Address = table.Column(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(type: "INTEGER", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(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(type: "INTEGER", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "TEXT", nullable: false), + AltName = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Professor", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TypeOfOccupation", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ShortName = table.Column(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(type: "INTEGER", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "TEXT", maxLength: 256, nullable: false), + 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); + }); + + migrationBuilder.CreateTable( + name: "LectureHall", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "TEXT", maxLength: 64, nullable: false), + 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); + }); + + migrationBuilder.CreateTable( + name: "Group", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "TEXT", maxLength: 64, nullable: false), + 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); + }); + + migrationBuilder.CreateTable( + name: "Lesson", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + IsEven = table.Column(type: "BOOLEAN", nullable: false), + DayOfWeek = table.Column(type: "INTEGER", nullable: false), + PairNumber = table.Column(type: "INTEGER", nullable: false), + IsExcludedWeeks = table.Column(type: "BOOLEAN", 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); + }); + + migrationBuilder.CreateTable( + name: "LessonAssociation", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + LinkToMeet = table.Column(type: "TEXT", maxLength: 512, nullable: true), + 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); + }); + + migrationBuilder.CreateTable( + name: "SpecificWeek", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + 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); + }); + + 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"); + } + } +} diff --git a/SqlData/Migrations/PsqlMigrations/Migrations/UberDbContextModelSnapshot.cs b/SqlData/Migrations/PsqlMigrations/Migrations/UberDbContextModelSnapshot.cs new file mode 100644 index 0000000..6039a03 --- /dev/null +++ b/SqlData/Migrations/PsqlMigrations/Migrations/UberDbContextModelSnapshot.cs @@ -0,0 +1,439 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Mirea.Api.DataAccess.Persistence; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace PsqlMigrations.Migrations +{ + [DbContext(typeof(UberDbContext))] + partial class UberDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property("CodeName") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("TEXT"); + + b.Property("FullName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Campus", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Discipline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Discipline", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CampusId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Faculty", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FacultyId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("FacultyId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Group", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CampusId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("LectureHall", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DayOfWeek") + .HasColumnType("INTEGER"); + + b.Property("DisciplineId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.Property("IsEven") + .HasColumnType("BOOLEAN"); + + b.Property("IsExcludedWeeks") + .HasColumnType("BOOLEAN"); + + b.Property("PairNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineId"); + + b.HasIndex("GroupId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Lesson", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LessonAssociation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LectureHallId") + .HasColumnType("INTEGER"); + + b.Property("LessonId") + .HasColumnType("INTEGER"); + + b.Property("LinkToMeet") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property("ProfessorId") + .HasColumnType("INTEGER"); + + b.Property("TypeOfOccupationId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LectureHallId"); + + b.HasIndex("LessonId"); + + b.HasIndex("ProfessorId"); + + b.HasIndex("TypeOfOccupationId"); + + b.ToTable("LessonAssociation", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Professor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AltName") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Professor", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.SpecificWeek", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LessonId") + .HasColumnType("INTEGER"); + + b.Property("WeekNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LessonId"); + + b.ToTable("SpecificWeek", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ShortName") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("TypeOfOccupation", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Campus", "Campus") + .WithMany("Faculties") + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Faculty", "Faculty") + .WithMany("Groups") + .HasForeignKey("FacultyId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Faculty"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Campus", "Campus") + .WithMany("LectureHalls") + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Discipline", "Discipline") + .WithMany("Lessons") + .HasForeignKey("DisciplineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Group", "Group") + .WithMany("Lessons") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Discipline"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LessonAssociation", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", "LectureHall") + .WithMany("LessonAssociations") + .HasForeignKey("LectureHallId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Lesson", "Lesson") + .WithMany("LessonAssociations") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Professor", "Professor") + .WithMany("LessonAssociations") + .HasForeignKey("ProfessorId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", "TypeOfOccupation") + .WithMany("Lessons") + .HasForeignKey("TypeOfOccupationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LectureHall"); + + b.Navigation("Lesson"); + + b.Navigation("Professor"); + + b.Navigation("TypeOfOccupation"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.SpecificWeek", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Lesson", "Lesson") + .WithMany("SpecificWeeks") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => + { + b.Navigation("Faculties"); + + b.Navigation("LectureHalls"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Discipline", b => + { + b.Navigation("Lessons"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.Navigation("Groups"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.Navigation("Lessons"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.Navigation("LessonAssociations"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.Navigation("LessonAssociations"); + + b.Navigation("SpecificWeeks"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Professor", b => + { + b.Navigation("LessonAssociations"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", b => + { + b.Navigation("Lessons"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/SqlData/Migrations/SqliteMigrations/Migrations/20240601015714_InitialMigration.Designer.cs b/SqlData/Migrations/SqliteMigrations/Migrations/20240601015714_InitialMigration.Designer.cs new file mode 100644 index 0000000..e100297 --- /dev/null +++ b/SqlData/Migrations/SqliteMigrations/Migrations/20240601015714_InitialMigration.Designer.cs @@ -0,0 +1,417 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Mirea.Api.DataAccess.Persistence; + +#nullable disable + +namespace SqliteMigrations.Migrations +{ + [DbContext(typeof(UberDbContext))] + [Migration("20240601015714_InitialMigration")] + partial class InitialMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Address") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property("CodeName") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("TEXT"); + + b.Property("FullName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Campus", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Discipline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Discipline", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CampusId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Faculty", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("FacultyId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("FacultyId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Group", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CampusId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("LectureHall", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DayOfWeek") + .HasColumnType("INTEGER"); + + b.Property("DisciplineId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.Property("IsEven") + .HasColumnType("BOOLEAN"); + + b.Property("IsExcludedWeeks") + .HasColumnType("BOOLEAN"); + + b.Property("PairNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineId"); + + b.HasIndex("GroupId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Lesson", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LessonAssociation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LectureHallId") + .HasColumnType("INTEGER"); + + b.Property("LessonId") + .HasColumnType("INTEGER"); + + b.Property("LinkToMeet") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property("ProfessorId") + .HasColumnType("INTEGER"); + + b.Property("TypeOfOccupationId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LectureHallId"); + + b.HasIndex("LessonId"); + + b.HasIndex("ProfessorId"); + + b.HasIndex("TypeOfOccupationId"); + + b.ToTable("LessonAssociation", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Professor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AltName") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Professor", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.SpecificWeek", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LessonId") + .HasColumnType("INTEGER"); + + b.Property("WeekNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LessonId"); + + b.ToTable("SpecificWeek", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ShortName") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("TypeOfOccupation", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Campus", "Campus") + .WithMany("Faculties") + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Faculty", "Faculty") + .WithMany("Groups") + .HasForeignKey("FacultyId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Faculty"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Campus", "Campus") + .WithMany("LectureHalls") + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Discipline", "Discipline") + .WithMany("Lessons") + .HasForeignKey("DisciplineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Group", "Group") + .WithMany("Lessons") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Discipline"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LessonAssociation", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", "LectureHall") + .WithMany("LessonAssociations") + .HasForeignKey("LectureHallId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Lesson", "Lesson") + .WithMany("LessonAssociations") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Professor", "Professor") + .WithMany("LessonAssociations") + .HasForeignKey("ProfessorId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", "TypeOfOccupation") + .WithMany("Lessons") + .HasForeignKey("TypeOfOccupationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LectureHall"); + + b.Navigation("Lesson"); + + b.Navigation("Professor"); + + b.Navigation("TypeOfOccupation"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.SpecificWeek", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Lesson", "Lesson") + .WithMany("SpecificWeeks") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => + { + b.Navigation("Faculties"); + + b.Navigation("LectureHalls"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Discipline", b => + { + b.Navigation("Lessons"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.Navigation("Groups"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.Navigation("Lessons"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.Navigation("LessonAssociations"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.Navigation("LessonAssociations"); + + b.Navigation("SpecificWeeks"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Professor", b => + { + b.Navigation("LessonAssociations"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", b => + { + b.Navigation("Lessons"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/SqlData/Migrations/SqliteMigrations/Migrations/20240601015714_InitialMigration.cs b/SqlData/Migrations/SqliteMigrations/Migrations/20240601015714_InitialMigration.cs new file mode 100644 index 0000000..9afa7f2 --- /dev/null +++ b/SqlData/Migrations/SqliteMigrations/Migrations/20240601015714_InitialMigration.cs @@ -0,0 +1,364 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SqliteMigrations.Migrations +{ + /// + public partial class InitialMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Campus", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + CodeName = table.Column(type: "TEXT", maxLength: 16, nullable: false), + FullName = table.Column(type: "TEXT", maxLength: 256, nullable: true), + Address = table.Column(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(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(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(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: false), + AltName = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Professor", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TypeOfOccupation", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + ShortName = table.Column(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(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", maxLength: 256, nullable: false), + 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); + }); + + migrationBuilder.CreateTable( + name: "LectureHall", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", maxLength: 64, nullable: false), + 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); + }); + + migrationBuilder.CreateTable( + name: "Group", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", maxLength: 64, nullable: false), + 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); + }); + + migrationBuilder.CreateTable( + name: "Lesson", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + IsEven = table.Column(type: "BOOLEAN", nullable: false), + DayOfWeek = table.Column(type: "INTEGER", nullable: false), + PairNumber = table.Column(type: "INTEGER", nullable: false), + IsExcludedWeeks = table.Column(type: "BOOLEAN", 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); + }); + + migrationBuilder.CreateTable( + name: "LessonAssociation", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + LinkToMeet = table.Column(type: "TEXT", maxLength: 512, nullable: true), + 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); + }); + + migrationBuilder.CreateTable( + name: "SpecificWeek", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + 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); + }); + + 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"); + } + } +} diff --git a/SqlData/Migrations/SqliteMigrations/Migrations/UberDbContextModelSnapshot.cs b/SqlData/Migrations/SqliteMigrations/Migrations/UberDbContextModelSnapshot.cs new file mode 100644 index 0000000..c463963 --- /dev/null +++ b/SqlData/Migrations/SqliteMigrations/Migrations/UberDbContextModelSnapshot.cs @@ -0,0 +1,414 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Mirea.Api.DataAccess.Persistence; + +#nullable disable + +namespace SqliteMigrations.Migrations +{ + [DbContext(typeof(UberDbContext))] + partial class UberDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Address") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property("CodeName") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("TEXT"); + + b.Property("FullName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Campus", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Discipline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Discipline", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CampusId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Faculty", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("FacultyId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("FacultyId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Group", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CampusId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("LectureHall", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DayOfWeek") + .HasColumnType("INTEGER"); + + b.Property("DisciplineId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.Property("IsEven") + .HasColumnType("BOOLEAN"); + + b.Property("IsExcludedWeeks") + .HasColumnType("BOOLEAN"); + + b.Property("PairNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineId"); + + b.HasIndex("GroupId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Lesson", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LessonAssociation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LectureHallId") + .HasColumnType("INTEGER"); + + b.Property("LessonId") + .HasColumnType("INTEGER"); + + b.Property("LinkToMeet") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property("ProfessorId") + .HasColumnType("INTEGER"); + + b.Property("TypeOfOccupationId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LectureHallId"); + + b.HasIndex("LessonId"); + + b.HasIndex("ProfessorId"); + + b.HasIndex("TypeOfOccupationId"); + + b.ToTable("LessonAssociation", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Professor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AltName") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Professor", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.SpecificWeek", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LessonId") + .HasColumnType("INTEGER"); + + b.Property("WeekNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LessonId"); + + b.ToTable("SpecificWeek", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ShortName") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("TypeOfOccupation", (string)null); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Campus", "Campus") + .WithMany("Faculties") + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Faculty", "Faculty") + .WithMany("Groups") + .HasForeignKey("FacultyId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Faculty"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Campus", "Campus") + .WithMany("LectureHalls") + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Discipline", "Discipline") + .WithMany("Lessons") + .HasForeignKey("DisciplineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Group", "Group") + .WithMany("Lessons") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Discipline"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LessonAssociation", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", "LectureHall") + .WithMany("LessonAssociations") + .HasForeignKey("LectureHallId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Lesson", "Lesson") + .WithMany("LessonAssociations") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Professor", "Professor") + .WithMany("LessonAssociations") + .HasForeignKey("ProfessorId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", "TypeOfOccupation") + .WithMany("Lessons") + .HasForeignKey("TypeOfOccupationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LectureHall"); + + b.Navigation("Lesson"); + + b.Navigation("Professor"); + + b.Navigation("TypeOfOccupation"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.SpecificWeek", b => + { + b.HasOne("Mirea.Api.DataAccess.Domain.Schedule.Lesson", "Lesson") + .WithMany("SpecificWeeks") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => + { + b.Navigation("Faculties"); + + b.Navigation("LectureHalls"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Discipline", b => + { + b.Navigation("Lessons"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Faculty", b => + { + b.Navigation("Groups"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Group", b => + { + b.Navigation("Lessons"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.LectureHall", b => + { + b.Navigation("LessonAssociations"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Lesson", b => + { + b.Navigation("LessonAssociations"); + + b.Navigation("SpecificWeeks"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Professor", b => + { + b.Navigation("LessonAssociations"); + }); + + modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.TypeOfOccupation", b => + { + b.Navigation("Lessons"); + }); +#pragma warning restore 612, 618 + } + } +}