From dead9f89bb3562f1e77149dd1a5770f951d70b2f Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Sun, 27 Oct 2024 06:50:47 +0300 Subject: [PATCH] feat: remove unused ref campus --- ApiDto/Responses/FacultyDetailsResponse.cs | 36 -- ApiDto/Responses/FacultyResponse.cs | 5 - Endpoint/Controllers/V1/FacultyController.cs | 29 +- SqlData/Application/Application.csproj | 6 +- .../GetFacultyDetails/FacultyInfoVm.cs | 32 -- .../GetFacultyDetails/GetFacultyInfoQuery.cs | 8 - .../GetFacultyInfoQueryHandler.cs | 27 -- .../GetFacultyListQueryHandler.cs | 3 +- SqlData/Domain/Domain.csproj | 6 +- SqlData/Domain/Schedule/Campus.cs | 1 - SqlData/Domain/Schedule/Faculty.cs | 3 - ...20241027034820_RemoveUnusedRef.Designer.cs | 425 ++++++++++++++++++ .../20241027034820_RemoveUnusedRef.cs | 83 ++++ .../Migrations/UberDbContextModelSnapshot.cs | 23 +- ...20241027032753_RemoveUnusedRef.Designer.cs | 425 ++++++++++++++++++ .../20241027032753_RemoveUnusedRef.cs | 49 ++ .../Migrations/UberDbContextModelSnapshot.cs | 19 +- ...20241027032931_RemoveUnusedRef.Designer.cs | 400 +++++++++++++++++ .../20241027032931_RemoveUnusedRef.cs | 49 ++ .../Migrations/UberDbContextModelSnapshot.cs | 19 +- .../Mysql/Schedule/FacultyConfiguration.cs | 8 - .../Schedule/FacultyConfiguration.cs | 8 - .../Sqlite/Schedule/FacultyConfiguration.cs | 8 - SqlData/Persistence/Persistence.csproj | 6 +- 24 files changed, 1447 insertions(+), 231 deletions(-) delete mode 100644 ApiDto/Responses/FacultyDetailsResponse.cs delete mode 100644 SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/FacultyInfoVm.cs delete mode 100644 SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQuery.cs delete mode 100644 SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQueryHandler.cs create mode 100644 SqlData/Migrations/MysqlMigrations/Migrations/20241027034820_RemoveUnusedRef.Designer.cs create mode 100644 SqlData/Migrations/MysqlMigrations/Migrations/20241027034820_RemoveUnusedRef.cs create mode 100644 SqlData/Migrations/PsqlMigrations/Migrations/20241027032753_RemoveUnusedRef.Designer.cs create mode 100644 SqlData/Migrations/PsqlMigrations/Migrations/20241027032753_RemoveUnusedRef.cs create mode 100644 SqlData/Migrations/SqliteMigrations/Migrations/20241027032931_RemoveUnusedRef.Designer.cs create mode 100644 SqlData/Migrations/SqliteMigrations/Migrations/20241027032931_RemoveUnusedRef.cs diff --git a/ApiDto/Responses/FacultyDetailsResponse.cs b/ApiDto/Responses/FacultyDetailsResponse.cs deleted file mode 100644 index 09c863b..0000000 --- a/ApiDto/Responses/FacultyDetailsResponse.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Mirea.Api.Dto.Responses; - -/// -/// Represents detailed information about a faculty. -/// -public class FacultyDetailsResponse -{ - /// - /// Gets or sets the unique identifier of the faculty. - /// - [Required] - public int Id { get; set; } - - /// - /// Gets or sets the name of the faculty. - /// - [Required] - public required string Name { get; set; } - - /// - /// Gets or sets the unique identifier of the campus to which the faculty belongs (optional). - /// - public int? CampusId { get; set; } - - /// - /// Gets or sets the name of the campus to which the faculty belongs (optional). - /// - public string? CampusName { get; set; } - - /// - /// Gets or sets the code name of the campus to which the faculty belongs (optional). - /// - public string? CampusCode { get; set; } -} \ No newline at end of file diff --git a/ApiDto/Responses/FacultyResponse.cs b/ApiDto/Responses/FacultyResponse.cs index adcf127..1e172c2 100644 --- a/ApiDto/Responses/FacultyResponse.cs +++ b/ApiDto/Responses/FacultyResponse.cs @@ -18,9 +18,4 @@ public class FacultyResponse /// [Required] public required string Name { get; set; } - - /// - /// Gets or sets the unique identifier of the campus to which the faculty belongs (optional). - /// - public int? CampusId { get; set; } } \ No newline at end of file diff --git a/Endpoint/Controllers/V1/FacultyController.cs b/Endpoint/Controllers/V1/FacultyController.cs index 56c88ad..3b5af11 100644 --- a/Endpoint/Controllers/V1/FacultyController.cs +++ b/Endpoint/Controllers/V1/FacultyController.cs @@ -1,7 +1,6 @@ using Asp.Versioning; using MediatR; using Microsoft.AspNetCore.Mvc; -using Mirea.Api.DataAccess.Application.Cqrs.Faculty.Queries.GetFacultyDetails; using Mirea.Api.DataAccess.Application.Cqrs.Faculty.Queries.GetFacultyList; using Mirea.Api.Dto.Responses; using Mirea.Api.Endpoint.Common.Attributes; @@ -35,34 +34,8 @@ public class FacultyController(IMediator mediator) : BaseController .Select(f => new FacultyResponse() { Id = f.Id, - Name = f.Name, - CampusId = f.CampusId + Name = f.Name }) ); } - - /// - /// Gets details of a specific faculty by ID. - /// - /// Faculty ID. - /// Details of the specified faculty. - [HttpGet("{id:int}")] - [BadRequestResponse] - [NotFoundResponse] - public async Task> GetDetails(int id) - { - var result = await mediator.Send(new GetFacultyInfoQuery() - { - Id = id - }); - - return Ok(new FacultyDetailsResponse() - { - Id = result.Id, - Name = result.Name, - CampusId = result.CampusId, - CampusCode = result.CampusCode, - CampusName = result.CampusName - }); - } } \ No newline at end of file diff --git a/SqlData/Application/Application.csproj b/SqlData/Application/Application.csproj index 822bf16..1062253 100644 --- a/SqlData/Application/Application.csproj +++ b/SqlData/Application/Application.csproj @@ -5,9 +5,9 @@ disable enable Winsomnia - 1.0.1 - 1.0.3.1 - 1.0.3.1 + 1.0.2 + 1.0.3.2 + 1.0.3.2 Mirea.Api.DataAccess.Application $(AssemblyName) diff --git a/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/FacultyInfoVm.cs b/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/FacultyInfoVm.cs deleted file mode 100644 index f7fb805..0000000 --- a/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/FacultyInfoVm.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace Mirea.Api.DataAccess.Application.Cqrs.Faculty.Queries.GetFacultyDetails; - -/// -/// Represents faculties. -/// -public class FacultyInfoVm -{ - /// - /// The unique identifier for the faculty. - /// - public int Id { get; set; } - - /// - /// The name of the faculty. - /// - public required string Name { get; set; } - - /// - /// ID indicating the faculty's affiliation to the campus. - /// - public int? CampusId { get; set; } - - /// - /// Campus name indicating the faculty's affiliation to the campus. - /// - public string? CampusName { get; set; } - - /// - /// Campus code indicating the faculty's affiliation to the campus. - /// - public string? CampusCode { get; set; } -} \ No newline at end of file diff --git a/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQuery.cs b/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQuery.cs deleted file mode 100644 index 2517b14..0000000 --- a/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQuery.cs +++ /dev/null @@ -1,8 +0,0 @@ -using MediatR; - -namespace Mirea.Api.DataAccess.Application.Cqrs.Faculty.Queries.GetFacultyDetails; - -public class GetFacultyInfoQuery : IRequest -{ - public required int Id { get; set; } -} \ No newline at end of file diff --git a/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQueryHandler.cs b/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQueryHandler.cs deleted file mode 100644 index a2f6486..0000000 --- a/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQueryHandler.cs +++ /dev/null @@ -1,27 +0,0 @@ -using MediatR; -using Microsoft.EntityFrameworkCore; -using Mirea.Api.DataAccess.Application.Common.Exceptions; -using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; -using System.Threading; -using System.Threading.Tasks; - -namespace Mirea.Api.DataAccess.Application.Cqrs.Faculty.Queries.GetFacultyDetails; - -public class GetFacultyInfoQueryHandler(IFacultyDbContext dbContext) : IRequestHandler -{ - public async Task Handle(GetFacultyInfoQuery request, CancellationToken cancellationToken) - { - var faculty = await dbContext.Faculties - .Include(f => f.Campus) - .FirstOrDefaultAsync(f => f.Id == request.Id, cancellationToken) ?? throw new NotFoundException(typeof(Domain.Schedule.Faculty), request.Id); - - return new FacultyInfoVm() - { - Id = faculty.Id, - Name = faculty.Name, - CampusId = faculty.CampusId, - CampusName = faculty.Campus?.FullName, - CampusCode = faculty.Campus?.CodeName - }; - } -} \ No newline at end of file diff --git a/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyList/GetFacultyListQueryHandler.cs b/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyList/GetFacultyListQueryHandler.cs index 1249fe7..d84b3a4 100644 --- a/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyList/GetFacultyListQueryHandler.cs +++ b/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyList/GetFacultyListQueryHandler.cs @@ -14,8 +14,7 @@ public class GetFacultyListQueryHandler(IFacultyDbContext dbContext) : IRequestH var dtos = dbContext.Faculties.OrderBy(f => f.Id).Select(f => new FacultyLookupDto() { Id = f.Id, - Name = f.Name, - CampusId = f.CampusId + Name = f.Name }); if (request is { PageSize: not null, Page: not null }) diff --git a/SqlData/Domain/Domain.csproj b/SqlData/Domain/Domain.csproj index 940e1f5..a3244e6 100644 --- a/SqlData/Domain/Domain.csproj +++ b/SqlData/Domain/Domain.csproj @@ -5,9 +5,9 @@ disable enable Winsomnia - 1.0.0 - 1.0.3.0 - 1.0.3.0 + 1.0.1 + 1.0.3.1 + 1.0.3.1 Mirea.Api.DataAccess.Domain $(AssemblyName) diff --git a/SqlData/Domain/Schedule/Campus.cs b/SqlData/Domain/Schedule/Campus.cs index dde6d2d..fc6b158 100644 --- a/SqlData/Domain/Schedule/Campus.cs +++ b/SqlData/Domain/Schedule/Campus.cs @@ -9,6 +9,5 @@ public class Campus public string? FullName { get; set; } public string? Address { get; set; } - public List? Faculties { get; set; } public List? LectureHalls { get; set; } } \ No newline at end of file diff --git a/SqlData/Domain/Schedule/Faculty.cs b/SqlData/Domain/Schedule/Faculty.cs index cf87fa7..1f7682f 100644 --- a/SqlData/Domain/Schedule/Faculty.cs +++ b/SqlData/Domain/Schedule/Faculty.cs @@ -7,8 +7,5 @@ public class Faculty public int Id { get; set; } public required string Name { get; set; } - public int? CampusId { get; set; } - public Campus? Campus { get; set; } - public List? Groups { get; set; } } \ No newline at end of file diff --git a/SqlData/Migrations/MysqlMigrations/Migrations/20241027034820_RemoveUnusedRef.Designer.cs b/SqlData/Migrations/MysqlMigrations/Migrations/20241027034820_RemoveUnusedRef.Designer.cs new file mode 100644 index 0000000..ef398f9 --- /dev/null +++ b/SqlData/Migrations/MysqlMigrations/Migrations/20241027034820_RemoveUnusedRef.Designer.cs @@ -0,0 +1,425 @@ +// +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("20241027034820_RemoveUnusedRef")] + partial class RemoveUnusedRef + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .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("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + 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("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"); + + 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.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("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/20241027034820_RemoveUnusedRef.cs b/SqlData/Migrations/MysqlMigrations/Migrations/20241027034820_RemoveUnusedRef.cs new file mode 100644 index 0000000..e990751 --- /dev/null +++ b/SqlData/Migrations/MysqlMigrations/Migrations/20241027034820_RemoveUnusedRef.cs @@ -0,0 +1,83 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MysqlMigrations.Migrations +{ + /// + public partial class RemoveUnusedRef : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Faculty_Campus_CampusId", + table: "Faculty"); + + migrationBuilder.DropIndex( + name: "IX_Faculty_CampusId", + table: "Faculty"); + + migrationBuilder.DropColumn( + name: "CampusId", + table: "Faculty"); + + migrationBuilder.AlterColumn( + name: "IsExcludedWeeks", + table: "Lesson", + type: "BOOLEAN(1)", + nullable: true, + oldClrType: typeof(ulong), + oldType: "BIT(1)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsEven", + table: "Lesson", + type: "BOOLEAN(1)", + nullable: false, + oldClrType: typeof(ulong), + oldType: "BIT(1)"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "IsExcludedWeeks", + table: "Lesson", + type: "BIT(1)", + nullable: true, + oldClrType: typeof(bool), + oldType: "BOOLEAN(1)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsEven", + table: "Lesson", + type: "BIT(1)", + nullable: false, + oldClrType: typeof(bool), + oldType: "BOOLEAN(1)"); + + migrationBuilder.AddColumn( + name: "CampusId", + table: "Faculty", + type: "INTEGER", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Faculty_CampusId", + table: "Faculty", + column: "CampusId"); + + migrationBuilder.AddForeignKey( + name: "FK_Faculty_Campus_CampusId", + table: "Faculty", + column: "CampusId", + principalTable: "Campus", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + } + } +} diff --git a/SqlData/Migrations/MysqlMigrations/Migrations/UberDbContextModelSnapshot.cs b/SqlData/Migrations/MysqlMigrations/Migrations/UberDbContextModelSnapshot.cs index 5e0b48f..dcd0999 100644 --- a/SqlData/Migrations/MysqlMigrations/Migrations/UberDbContextModelSnapshot.cs +++ b/SqlData/Migrations/MysqlMigrations/Migrations/UberDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ namespace MysqlMigrations.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("ProductVersion", "8.0.10") .HasAnnotation("Relational:MaxIdentifierLength", 64); MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); @@ -80,9 +80,6 @@ namespace MysqlMigrations.Migrations MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - b.Property("CampusId") - .HasColumnType("INTEGER"); - b.Property("Name") .IsRequired() .HasMaxLength(256) @@ -90,8 +87,6 @@ namespace MysqlMigrations.Migrations b.HasKey("Id"); - b.HasIndex("CampusId"); - b.HasIndex("Id") .IsUnique(); @@ -168,10 +163,10 @@ namespace MysqlMigrations.Migrations .HasColumnType("INTEGER"); b.Property("IsEven") - .HasColumnType("BIT(1)"); + .HasColumnType("BOOLEAN"); b.Property("IsExcludedWeeks") - .HasColumnType("BIT(1)"); + .HasColumnType("BOOLEAN"); b.Property("PairNumber") .HasColumnType("INTEGER"); @@ -296,16 +291,6 @@ namespace MysqlMigrations.Migrations 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") @@ -392,8 +377,6 @@ namespace MysqlMigrations.Migrations modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => { - b.Navigation("Faculties"); - b.Navigation("LectureHalls"); }); diff --git a/SqlData/Migrations/PsqlMigrations/Migrations/20241027032753_RemoveUnusedRef.Designer.cs b/SqlData/Migrations/PsqlMigrations/Migrations/20241027032753_RemoveUnusedRef.Designer.cs new file mode 100644 index 0000000..3803c85 --- /dev/null +++ b/SqlData/Migrations/PsqlMigrations/Migrations/20241027032753_RemoveUnusedRef.Designer.cs @@ -0,0 +1,425 @@ +// +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("20241027032753_RemoveUnusedRef")] + partial class RemoveUnusedRef + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .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("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + 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.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("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/20241027032753_RemoveUnusedRef.cs b/SqlData/Migrations/PsqlMigrations/Migrations/20241027032753_RemoveUnusedRef.cs new file mode 100644 index 0000000..1589fd5 --- /dev/null +++ b/SqlData/Migrations/PsqlMigrations/Migrations/20241027032753_RemoveUnusedRef.cs @@ -0,0 +1,49 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace PsqlMigrations.Migrations +{ + /// + public partial class RemoveUnusedRef : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Faculty_Campus_CampusId", + table: "Faculty"); + + migrationBuilder.DropIndex( + name: "IX_Faculty_CampusId", + table: "Faculty"); + + migrationBuilder.DropColumn( + name: "CampusId", + table: "Faculty"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CampusId", + table: "Faculty", + type: "INTEGER", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Faculty_CampusId", + table: "Faculty", + column: "CampusId"); + + migrationBuilder.AddForeignKey( + name: "FK_Faculty_Campus_CampusId", + table: "Faculty", + column: "CampusId", + principalTable: "Campus", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + } + } +} diff --git a/SqlData/Migrations/PsqlMigrations/Migrations/UberDbContextModelSnapshot.cs b/SqlData/Migrations/PsqlMigrations/Migrations/UberDbContextModelSnapshot.cs index 6039a03..10dcf26 100644 --- a/SqlData/Migrations/PsqlMigrations/Migrations/UberDbContextModelSnapshot.cs +++ b/SqlData/Migrations/PsqlMigrations/Migrations/UberDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ namespace PsqlMigrations.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("ProductVersion", "8.0.10") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -80,9 +80,6 @@ namespace PsqlMigrations.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("CampusId") - .HasColumnType("INTEGER"); - b.Property("Name") .IsRequired() .HasMaxLength(256) @@ -90,8 +87,6 @@ namespace PsqlMigrations.Migrations b.HasKey("Id"); - b.HasIndex("CampusId"); - b.HasIndex("Id") .IsUnique(); @@ -296,16 +291,6 @@ namespace PsqlMigrations.Migrations 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") @@ -392,8 +377,6 @@ namespace PsqlMigrations.Migrations modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => { - b.Navigation("Faculties"); - b.Navigation("LectureHalls"); }); diff --git a/SqlData/Migrations/SqliteMigrations/Migrations/20241027032931_RemoveUnusedRef.Designer.cs b/SqlData/Migrations/SqliteMigrations/Migrations/20241027032931_RemoveUnusedRef.Designer.cs new file mode 100644 index 0000000..9b53069 --- /dev/null +++ b/SqlData/Migrations/SqliteMigrations/Migrations/20241027032931_RemoveUnusedRef.Designer.cs @@ -0,0 +1,400 @@ +// +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("20241027032931_RemoveUnusedRef")] + partial class RemoveUnusedRef + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.10"); + + 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("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + 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.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("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/20241027032931_RemoveUnusedRef.cs b/SqlData/Migrations/SqliteMigrations/Migrations/20241027032931_RemoveUnusedRef.cs new file mode 100644 index 0000000..4fcdfcc --- /dev/null +++ b/SqlData/Migrations/SqliteMigrations/Migrations/20241027032931_RemoveUnusedRef.cs @@ -0,0 +1,49 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SqliteMigrations.Migrations +{ + /// + public partial class RemoveUnusedRef : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Faculty_Campus_CampusId", + table: "Faculty"); + + migrationBuilder.DropIndex( + name: "IX_Faculty_CampusId", + table: "Faculty"); + + migrationBuilder.DropColumn( + name: "CampusId", + table: "Faculty"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CampusId", + table: "Faculty", + type: "INTEGER", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Faculty_CampusId", + table: "Faculty", + column: "CampusId"); + + migrationBuilder.AddForeignKey( + name: "FK_Faculty_Campus_CampusId", + table: "Faculty", + column: "CampusId", + principalTable: "Campus", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + } + } +} diff --git a/SqlData/Migrations/SqliteMigrations/Migrations/UberDbContextModelSnapshot.cs b/SqlData/Migrations/SqliteMigrations/Migrations/UberDbContextModelSnapshot.cs index c463963..2834b48 100644 --- a/SqlData/Migrations/SqliteMigrations/Migrations/UberDbContextModelSnapshot.cs +++ b/SqlData/Migrations/SqliteMigrations/Migrations/UberDbContextModelSnapshot.cs @@ -15,7 +15,7 @@ namespace SqliteMigrations.Migrations protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); + modelBuilder.HasAnnotation("ProductVersion", "8.0.10"); modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => { @@ -69,9 +69,6 @@ namespace SqliteMigrations.Migrations .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); - b.Property("CampusId") - .HasColumnType("INTEGER"); - b.Property("Name") .IsRequired() .HasMaxLength(256) @@ -79,8 +76,6 @@ namespace SqliteMigrations.Migrations b.HasKey("Id"); - b.HasIndex("CampusId"); - b.HasIndex("Id") .IsUnique(); @@ -271,16 +266,6 @@ namespace SqliteMigrations.Migrations 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") @@ -367,8 +352,6 @@ namespace SqliteMigrations.Migrations modelBuilder.Entity("Mirea.Api.DataAccess.Domain.Schedule.Campus", b => { - b.Navigation("Faculties"); - b.Navigation("LectureHalls"); }); diff --git a/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/FacultyConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/FacultyConfiguration.cs index 3e2e24d..8eede85 100644 --- a/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/FacultyConfiguration.cs +++ b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/FacultyConfiguration.cs @@ -14,13 +14,5 @@ public class FacultyConfiguration : IEntityTypeConfiguration builder.Property(f => f.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd(); builder.Property(f => f.Name).HasColumnType("VARCHAR(256)").IsRequired().HasMaxLength(256); - - builder.Property(f => f.CampusId).HasColumnType("INT"); - - builder - .HasOne(f => f.Campus) - .WithMany(c => c.Faculties) - .HasForeignKey(c => c.CampusId) - .OnDelete(DeleteBehavior.SetNull); } } \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/FacultyConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/FacultyConfiguration.cs index 05f622f..a270346 100644 --- a/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/FacultyConfiguration.cs +++ b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/FacultyConfiguration.cs @@ -14,13 +14,5 @@ public class FacultyConfiguration : IEntityTypeConfiguration builder.Property(f => f.Id).HasColumnType("serial").IsRequired().ValueGeneratedOnAdd(); builder.Property(f => f.Name).HasColumnType("text").IsRequired().HasMaxLength(256); - - builder.Property(f => f.CampusId).HasColumnType("serial"); - - builder - .HasOne(f => f.Campus) - .WithMany(c => c.Faculties) - .HasForeignKey(c => c.CampusId) - .OnDelete(DeleteBehavior.SetNull); } } \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/FacultyConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/FacultyConfiguration.cs index c7cde69..31d974f 100644 --- a/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/FacultyConfiguration.cs +++ b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/FacultyConfiguration.cs @@ -14,13 +14,5 @@ public class FacultyConfiguration : IEntityTypeConfiguration builder.Property(f => f.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd(); builder.Property(f => f.Name).HasColumnType("TEXT").IsRequired().HasMaxLength(256); - - builder.Property(f => f.CampusId).HasColumnType("INTEGER"); - - builder - .HasOne(f => f.Campus) - .WithMany(c => c.Faculties) - .HasForeignKey(c => c.CampusId) - .OnDelete(DeleteBehavior.SetNull); } } \ No newline at end of file diff --git a/SqlData/Persistence/Persistence.csproj b/SqlData/Persistence/Persistence.csproj index 3008d4e..433daa1 100644 --- a/SqlData/Persistence/Persistence.csproj +++ b/SqlData/Persistence/Persistence.csproj @@ -5,9 +5,9 @@ disable enable Winsomnia - 1.0.1 - 1.0.3.1 - 1.0.3.1 + 1.0.2 + 1.0.3.2 + 1.0.3.2 Mirea.Api.DataAccess.Persistence $(AssemblyName)