diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index 49484d4..9d784b5 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -2,17 +2,19 @@ name: .NET Test Pipeline on: pull_request: - branches: [master, 'release/*'] + push: + branches: + [master, 'release/*'] jobs: build-and-test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up .NET Core - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x diff --git a/Application/Common/Mappings/AssemblyMappingProfile.cs b/Application/Common/Mappings/AssemblyMappingProfile.cs deleted file mode 100644 index 68a9e8e..0000000 --- a/Application/Common/Mappings/AssemblyMappingProfile.cs +++ /dev/null @@ -1,28 +0,0 @@ -using AutoMapper; -using System; -using System.Linq; -using System.Reflection; - -namespace Mirea.Api.DataAccess.Application.Common.Mappings; - -public class AssemblyMappingProfile : Profile -{ - public AssemblyMappingProfile(Assembly assembly) => - ApplyMappingsFromAssembly(assembly); - - private void ApplyMappingsFromAssembly(Assembly assembly) - { - var types = assembly.GetExportedTypes() - .Where(type => type.GetInterfaces() - .Any(i => i.IsGenericType && - i.GetGenericTypeDefinition() == typeof(IMapWith<>))) - .ToList(); - - foreach (var type in types) - { - var instance = Activator.CreateInstance(type); - var methodInfo = type.GetMethod("Mapping"); - methodInfo?.Invoke(instance, new[] { this }); - } - } -} \ No newline at end of file diff --git a/Application/Common/Mappings/IMapWith.cs b/Application/Common/Mappings/IMapWith.cs deleted file mode 100644 index 390e4e0..0000000 --- a/Application/Common/Mappings/IMapWith.cs +++ /dev/null @@ -1,9 +0,0 @@ -using AutoMapper; - -namespace Mirea.Api.DataAccess.Application.Common.Mappings; - -public interface IMapWith -{ - void Mapping(Profile profile) => - profile.CreateMap(typeof(T), GetType()); -} \ No newline at end of file diff --git a/Backend.sln b/Backend.sln index 5790acf..81a8dbe 100644 --- a/Backend.sln +++ b/Backend.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.8.34330.188 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Domain", "Domain\Domain.csproj", "{C27FB5CD-6A70-4FB2-847A-847B34806902}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Endpoint", "Endpoint\Endpoint.csproj", "{F3A1D12E-F5B2-4339-9966-DBF869E78357}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Elements of the solution", "Elements of the solution", "{3E087889-A4A0-4A55-A07D-7D149A5BC928}" @@ -19,13 +17,34 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Elements of the solution", .gitea\workflows\test.yaml = .gitea\workflows\test.yaml EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Application", "Application\Application.csproj", "{E7F0A4D4-B032-4BB9-9526-1AF688F341A4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence", "Persistence\Persistence.csproj", "{4C1E558F-633F-438E-AC3A-61CDDED917C5}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiDto", "ApiDto\ApiDto.csproj", "{0335FA36-E137-453F-853B-916674C168FE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Security", "Security\Security.csproj", "{47A3C065-4E1D-4B1E-AAB4-2BB8F40E56B4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Security", "Security\Security.csproj", "{47A3C065-4E1D-4B1E-AAB4-2BB8F40E56B4}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SqlData", "SqlData", "{7E7A63CD-547B-4FB4-A383-EB75298020A1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Domain", "SqlData\Domain\Domain.csproj", "{3BFD6180-7CA7-4E85-A379-225B872439A1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Application", "SqlData\Application\Application.csproj", "{0B1F3656-E5B3-440C-961F-A7D004FBE9A8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence", "SqlData\Persistence\Persistence.csproj", "{48C9998C-ECE2-407F-835F-1A7255A5C99E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Migrations", "Migrations", "{79639CD4-7A16-4AB4-BBE8-672B9ACCB3F5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqliteMigrations", "SqlData\Migrations\SqliteMigrations\SqliteMigrations.csproj", "{EF5530BD-4BF4-4DD8-80BB-04C6B6623DA7}" + ProjectSection(ProjectDependencies) = postProject + {48C9998C-ECE2-407F-835F-1A7255A5C99E} = {48C9998C-ECE2-407F-835F-1A7255A5C99E} + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MysqlMigrations", "SqlData\Migrations\MysqlMigrations\MysqlMigrations.csproj", "{5861915B-9574-4D5D-872F-D54A09651697}" + ProjectSection(ProjectDependencies) = postProject + {48C9998C-ECE2-407F-835F-1A7255A5C99E} = {48C9998C-ECE2-407F-835F-1A7255A5C99E} + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PsqlMigrations", "SqlData\Migrations\PsqlMigrations\PsqlMigrations.csproj", "{E9E238CD-6DD8-4B29-8C36-C61F1168FCCD}" + ProjectSection(ProjectDependencies) = postProject + {48C9998C-ECE2-407F-835F-1A7255A5C99E} = {48C9998C-ECE2-407F-835F-1A7255A5C99E} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -33,22 +52,10 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C27FB5CD-6A70-4FB2-847A-847B34806902}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C27FB5CD-6A70-4FB2-847A-847B34806902}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C27FB5CD-6A70-4FB2-847A-847B34806902}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C27FB5CD-6A70-4FB2-847A-847B34806902}.Release|Any CPU.Build.0 = Release|Any CPU {F3A1D12E-F5B2-4339-9966-DBF869E78357}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F3A1D12E-F5B2-4339-9966-DBF869E78357}.Debug|Any CPU.Build.0 = Debug|Any CPU {F3A1D12E-F5B2-4339-9966-DBF869E78357}.Release|Any CPU.ActiveCfg = Release|Any CPU {F3A1D12E-F5B2-4339-9966-DBF869E78357}.Release|Any CPU.Build.0 = Release|Any CPU - {E7F0A4D4-B032-4BB9-9526-1AF688F341A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E7F0A4D4-B032-4BB9-9526-1AF688F341A4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E7F0A4D4-B032-4BB9-9526-1AF688F341A4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E7F0A4D4-B032-4BB9-9526-1AF688F341A4}.Release|Any CPU.Build.0 = Release|Any CPU - {4C1E558F-633F-438E-AC3A-61CDDED917C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4C1E558F-633F-438E-AC3A-61CDDED917C5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4C1E558F-633F-438E-AC3A-61CDDED917C5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4C1E558F-633F-438E-AC3A-61CDDED917C5}.Release|Any CPU.Build.0 = Release|Any CPU {0335FA36-E137-453F-853B-916674C168FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0335FA36-E137-453F-853B-916674C168FE}.Debug|Any CPU.Build.0 = Debug|Any CPU {0335FA36-E137-453F-853B-916674C168FE}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -57,10 +64,43 @@ Global {47A3C065-4E1D-4B1E-AAB4-2BB8F40E56B4}.Debug|Any CPU.Build.0 = Debug|Any CPU {47A3C065-4E1D-4B1E-AAB4-2BB8F40E56B4}.Release|Any CPU.ActiveCfg = Release|Any CPU {47A3C065-4E1D-4B1E-AAB4-2BB8F40E56B4}.Release|Any CPU.Build.0 = Release|Any CPU + {3BFD6180-7CA7-4E85-A379-225B872439A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3BFD6180-7CA7-4E85-A379-225B872439A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3BFD6180-7CA7-4E85-A379-225B872439A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3BFD6180-7CA7-4E85-A379-225B872439A1}.Release|Any CPU.Build.0 = Release|Any CPU + {0B1F3656-E5B3-440C-961F-A7D004FBE9A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0B1F3656-E5B3-440C-961F-A7D004FBE9A8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0B1F3656-E5B3-440C-961F-A7D004FBE9A8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0B1F3656-E5B3-440C-961F-A7D004FBE9A8}.Release|Any CPU.Build.0 = Release|Any CPU + {48C9998C-ECE2-407F-835F-1A7255A5C99E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {48C9998C-ECE2-407F-835F-1A7255A5C99E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {48C9998C-ECE2-407F-835F-1A7255A5C99E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {48C9998C-ECE2-407F-835F-1A7255A5C99E}.Release|Any CPU.Build.0 = Release|Any CPU + {EF5530BD-4BF4-4DD8-80BB-04C6B6623DA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF5530BD-4BF4-4DD8-80BB-04C6B6623DA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EF5530BD-4BF4-4DD8-80BB-04C6B6623DA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EF5530BD-4BF4-4DD8-80BB-04C6B6623DA7}.Release|Any CPU.Build.0 = Release|Any CPU + {5861915B-9574-4D5D-872F-D54A09651697}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5861915B-9574-4D5D-872F-D54A09651697}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5861915B-9574-4D5D-872F-D54A09651697}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5861915B-9574-4D5D-872F-D54A09651697}.Release|Any CPU.Build.0 = Release|Any CPU + {E9E238CD-6DD8-4B29-8C36-C61F1168FCCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E9E238CD-6DD8-4B29-8C36-C61F1168FCCD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E9E238CD-6DD8-4B29-8C36-C61F1168FCCD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E9E238CD-6DD8-4B29-8C36-C61F1168FCCD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {3BFD6180-7CA7-4E85-A379-225B872439A1} = {7E7A63CD-547B-4FB4-A383-EB75298020A1} + {0B1F3656-E5B3-440C-961F-A7D004FBE9A8} = {7E7A63CD-547B-4FB4-A383-EB75298020A1} + {48C9998C-ECE2-407F-835F-1A7255A5C99E} = {7E7A63CD-547B-4FB4-A383-EB75298020A1} + {79639CD4-7A16-4AB4-BBE8-672B9ACCB3F5} = {7E7A63CD-547B-4FB4-A383-EB75298020A1} + {EF5530BD-4BF4-4DD8-80BB-04C6B6623DA7} = {79639CD4-7A16-4AB4-BBE8-672B9ACCB3F5} + {5861915B-9574-4D5D-872F-D54A09651697} = {79639CD4-7A16-4AB4-BBE8-672B9ACCB3F5} + {E9E238CD-6DD8-4B29-8C36-C61F1168FCCD} = {79639CD4-7A16-4AB4-BBE8-672B9ACCB3F5} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E80A1224-87F5-4FEB-82AE-89006BE98B12} EndGlobalSection diff --git a/Endpoint/Configuration/General/Settings/DbSettings.cs b/Endpoint/Configuration/General/Settings/DbSettings.cs index f8ae35e..2fa5ff9 100644 --- a/Endpoint/Configuration/General/Settings/DbSettings.cs +++ b/Endpoint/Configuration/General/Settings/DbSettings.cs @@ -1,4 +1,6 @@ -using Mirea.Api.Endpoint.Configuration.General.Attributes; +using System; +using Mirea.Api.DataAccess.Persistence.Common; +using Mirea.Api.Endpoint.Configuration.General.Attributes; using Mirea.Api.Endpoint.Configuration.General.Interfaces; namespace Mirea.Api.Endpoint.Configuration.General.Settings; @@ -15,8 +17,15 @@ public class DbSettings : IIsConfigured public DatabaseEnum TypeDatabase { get; set; } public required string ConnectionStringSql { get; set; } - public bool IsConfigured() - { - return !string.IsNullOrEmpty(ConnectionStringSql); - } + public DatabaseProvider DatabaseProvider => + TypeDatabase switch + { + DatabaseEnum.PostgresSql => DatabaseProvider.Postgresql, + DatabaseEnum.Mysql => DatabaseProvider.Mysql, + DatabaseEnum.Sqlite => DatabaseProvider.Sqlite, + _ => throw new ArgumentOutOfRangeException() + }; + + public bool IsConfigured() => + !string.IsNullOrEmpty(ConnectionStringSql); } \ No newline at end of file diff --git a/Endpoint/Endpoint.csproj b/Endpoint/Endpoint.csproj index 985a730..bd7ee16 100644 --- a/Endpoint/Endpoint.csproj +++ b/Endpoint/Endpoint.csproj @@ -31,9 +31,12 @@ - - + + + + + \ No newline at end of file diff --git a/Endpoint/Program.cs b/Endpoint/Program.cs index 840504f..87756d9 100644 --- a/Endpoint/Program.cs +++ b/Endpoint/Program.cs @@ -10,11 +10,13 @@ using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; using Mirea.Api.DataAccess.Application; using Mirea.Api.DataAccess.Persistence; +using Mirea.Api.DataAccess.Persistence.Common; using Mirea.Api.Endpoint.Common.Interfaces; using Mirea.Api.Endpoint.Common.Services; using Mirea.Api.Endpoint.Common.Services.Security; using Mirea.Api.Endpoint.Configuration; using Mirea.Api.Endpoint.Configuration.General; +using Mirea.Api.Endpoint.Configuration.General.Settings; using Mirea.Api.Endpoint.Configuration.General.Validators; using Mirea.Api.Endpoint.Configuration.Swagger; using Mirea.Api.Endpoint.Middleware; @@ -114,8 +116,9 @@ public class Program builder.Configuration.AddJsonFile(PathBuilder.Combine(GeneralConfig.FilePath), optional: true, reloadOnChange: true); builder.Services.Configure(builder.Configuration); + var generalConfig = builder.Configuration.Get(); builder.Services.AddApplication(); - builder.Services.AddPersistence(builder.Configuration.Get()?.DbSettings?.ConnectionStringSql ?? string.Empty); + builder.Services.AddPersistence(generalConfig?.DbSettings?.DatabaseProvider ?? DatabaseProvider.Sqlite, generalConfig?.DbSettings?.ConnectionStringSql ?? string.Empty); builder.Services.AddControllers(); builder.Services.AddSingleton(); diff --git a/Persistence/DependencyInjection.cs b/Persistence/DependencyInjection.cs deleted file mode 100644 index f98052c..0000000 --- a/Persistence/DependencyInjection.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; -using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; -using Mirea.Api.DataAccess.Persistence.Contexts.Schedule; - -namespace Mirea.Api.DataAccess.Persistence; - -public static class DependencyInjection -{ - public static IServiceCollection AddPersistence(this IServiceCollection services, string connection) - { - services.AddDbContext(DbConfig); - services.AddDbContext(DbConfig); - services.AddDbContext(DbConfig); - services.AddDbContext(DbConfig); - services.AddDbContext(DbConfig); - services.AddDbContext(DbConfig); - services.AddDbContext(DbConfig); - services.AddDbContext(DbConfig); - services.AddDbContext(DbConfig); - services.AddDbContext(DbConfig); - - services.AddDbContext(DbConfig); - - services.AddScoped(provider => provider.GetService()!); - services.AddScoped(provider => provider.GetService()!); - services.AddScoped(provider => provider.GetService()!); - services.AddScoped(provider => provider.GetService()!); - services.AddScoped(provider => provider.GetService()!); - services.AddScoped(provider => provider.GetService()!); - services.AddScoped(provider => provider.GetService()!); - services.AddScoped(provider => provider.GetService()!); - services.AddScoped(provider => provider.GetService()!); - services.AddScoped(provider => provider.GetService()!); - - return services; - - void DbConfig(DbContextOptionsBuilder options) => options.UseSqlite(connection); - } -} \ No newline at end of file diff --git a/Application/Application.csproj b/SqlData/Application/Application.csproj similarity index 53% rename from Application/Application.csproj rename to SqlData/Application/Application.csproj index 2003517..51f04ad 100644 --- a/Application/Application.csproj +++ b/SqlData/Application/Application.csproj @@ -13,15 +13,14 @@ - - - - - + + + + - + \ No newline at end of file diff --git a/Application/Common/Behaviors/ValidationBehavior.cs b/SqlData/Application/Common/Behaviors/ValidationBehavior.cs similarity index 100% rename from Application/Common/Behaviors/ValidationBehavior.cs rename to SqlData/Application/Common/Behaviors/ValidationBehavior.cs diff --git a/Application/Common/Exceptions/NotFoundException.cs b/SqlData/Application/Common/Exceptions/NotFoundException.cs similarity index 100% rename from Application/Common/Exceptions/NotFoundException.cs rename to SqlData/Application/Common/Exceptions/NotFoundException.cs diff --git a/Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/CampusBasicInfoDto.cs b/SqlData/Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/CampusBasicInfoDto.cs similarity index 100% rename from Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/CampusBasicInfoDto.cs rename to SqlData/Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/CampusBasicInfoDto.cs diff --git a/Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/CampusBasicInfoVm.cs b/SqlData/Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/CampusBasicInfoVm.cs similarity index 100% rename from Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/CampusBasicInfoVm.cs rename to SqlData/Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/CampusBasicInfoVm.cs diff --git a/Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/GetCampusBasicInfoListQuery.cs b/SqlData/Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/GetCampusBasicInfoListQuery.cs similarity index 100% rename from Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/GetCampusBasicInfoListQuery.cs rename to SqlData/Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/GetCampusBasicInfoListQuery.cs diff --git a/Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/GetCampusBasicInfoListQueryHandler.cs b/SqlData/Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/GetCampusBasicInfoListQueryHandler.cs similarity index 100% rename from Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/GetCampusBasicInfoListQueryHandler.cs rename to SqlData/Application/Cqrs/Campus/Queries/GetCampusBasicInfoList/GetCampusBasicInfoListQueryHandler.cs diff --git a/Application/Cqrs/Campus/Queries/GetCampusDetails/CampusDetailsVm.cs b/SqlData/Application/Cqrs/Campus/Queries/GetCampusDetails/CampusDetailsVm.cs similarity index 100% rename from Application/Cqrs/Campus/Queries/GetCampusDetails/CampusDetailsVm.cs rename to SqlData/Application/Cqrs/Campus/Queries/GetCampusDetails/CampusDetailsVm.cs diff --git a/Application/Cqrs/Campus/Queries/GetCampusDetails/GetCampusDetailsQuery.cs b/SqlData/Application/Cqrs/Campus/Queries/GetCampusDetails/GetCampusDetailsQuery.cs similarity index 100% rename from Application/Cqrs/Campus/Queries/GetCampusDetails/GetCampusDetailsQuery.cs rename to SqlData/Application/Cqrs/Campus/Queries/GetCampusDetails/GetCampusDetailsQuery.cs diff --git a/Application/Cqrs/Campus/Queries/GetCampusDetails/GetCampusDetailsQueryHandler.cs b/SqlData/Application/Cqrs/Campus/Queries/GetCampusDetails/GetCampusDetailsQueryHandler.cs similarity index 100% rename from Application/Cqrs/Campus/Queries/GetCampusDetails/GetCampusDetailsQueryHandler.cs rename to SqlData/Application/Cqrs/Campus/Queries/GetCampusDetails/GetCampusDetailsQueryHandler.cs diff --git a/Application/Cqrs/Discipline/Queries/GetDisciplineDetails/DisciplineInfoVm.cs b/SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineDetails/DisciplineInfoVm.cs similarity index 100% rename from Application/Cqrs/Discipline/Queries/GetDisciplineDetails/DisciplineInfoVm.cs rename to SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineDetails/DisciplineInfoVm.cs diff --git a/Application/Cqrs/Discipline/Queries/GetDisciplineDetails/GetDisciplineInfoQuery.cs b/SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineDetails/GetDisciplineInfoQuery.cs similarity index 100% rename from Application/Cqrs/Discipline/Queries/GetDisciplineDetails/GetDisciplineInfoQuery.cs rename to SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineDetails/GetDisciplineInfoQuery.cs diff --git a/Application/Cqrs/Discipline/Queries/GetDisciplineDetails/GetDisciplineInfoQueryHandler.cs b/SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineDetails/GetDisciplineInfoQueryHandler.cs similarity index 100% rename from Application/Cqrs/Discipline/Queries/GetDisciplineDetails/GetDisciplineInfoQueryHandler.cs rename to SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineDetails/GetDisciplineInfoQueryHandler.cs diff --git a/Application/Cqrs/Discipline/Queries/GetDisciplineList/DisciplineListVm.cs b/SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineList/DisciplineListVm.cs similarity index 100% rename from Application/Cqrs/Discipline/Queries/GetDisciplineList/DisciplineListVm.cs rename to SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineList/DisciplineListVm.cs diff --git a/Application/Cqrs/Discipline/Queries/GetDisciplineList/DisciplineLookupDto.cs b/SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineList/DisciplineLookupDto.cs similarity index 100% rename from Application/Cqrs/Discipline/Queries/GetDisciplineList/DisciplineLookupDto.cs rename to SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineList/DisciplineLookupDto.cs diff --git a/Application/Cqrs/Discipline/Queries/GetDisciplineList/GetDisciplineListQuery.cs b/SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineList/GetDisciplineListQuery.cs similarity index 100% rename from Application/Cqrs/Discipline/Queries/GetDisciplineList/GetDisciplineListQuery.cs rename to SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineList/GetDisciplineListQuery.cs diff --git a/Application/Cqrs/Discipline/Queries/GetDisciplineList/GetDisciplineListQueryHandler.cs b/SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineList/GetDisciplineListQueryHandler.cs similarity index 100% rename from Application/Cqrs/Discipline/Queries/GetDisciplineList/GetDisciplineListQueryHandler.cs rename to SqlData/Application/Cqrs/Discipline/Queries/GetDisciplineList/GetDisciplineListQueryHandler.cs diff --git a/Application/Cqrs/Faculty/Queries/GetFacultyDetails/FacultyInfoVm.cs b/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/FacultyInfoVm.cs similarity index 100% rename from Application/Cqrs/Faculty/Queries/GetFacultyDetails/FacultyInfoVm.cs rename to SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/FacultyInfoVm.cs diff --git a/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQuery.cs b/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQuery.cs similarity index 100% rename from Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQuery.cs rename to SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQuery.cs diff --git a/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQueryHandler.cs b/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQueryHandler.cs similarity index 100% rename from Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQueryHandler.cs rename to SqlData/Application/Cqrs/Faculty/Queries/GetFacultyDetails/GetFacultyInfoQueryHandler.cs diff --git a/Application/Cqrs/Faculty/Queries/GetFacultyList/FacultyListVm.cs b/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyList/FacultyListVm.cs similarity index 100% rename from Application/Cqrs/Faculty/Queries/GetFacultyList/FacultyListVm.cs rename to SqlData/Application/Cqrs/Faculty/Queries/GetFacultyList/FacultyListVm.cs diff --git a/Application/Cqrs/Faculty/Queries/GetFacultyList/FacultyLookupDto.cs b/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyList/FacultyLookupDto.cs similarity index 100% rename from Application/Cqrs/Faculty/Queries/GetFacultyList/FacultyLookupDto.cs rename to SqlData/Application/Cqrs/Faculty/Queries/GetFacultyList/FacultyLookupDto.cs diff --git a/Application/Cqrs/Faculty/Queries/GetFacultyList/GetFacultyListQuery.cs b/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyList/GetFacultyListQuery.cs similarity index 100% rename from Application/Cqrs/Faculty/Queries/GetFacultyList/GetFacultyListQuery.cs rename to SqlData/Application/Cqrs/Faculty/Queries/GetFacultyList/GetFacultyListQuery.cs diff --git a/Application/Cqrs/Faculty/Queries/GetFacultyList/GetFacultyListQueryHandler.cs b/SqlData/Application/Cqrs/Faculty/Queries/GetFacultyList/GetFacultyListQueryHandler.cs similarity index 100% rename from Application/Cqrs/Faculty/Queries/GetFacultyList/GetFacultyListQueryHandler.cs rename to SqlData/Application/Cqrs/Faculty/Queries/GetFacultyList/GetFacultyListQueryHandler.cs diff --git a/Application/Cqrs/Group/Queries/GetGroupDetails/GetGroupInfoQuery.cs b/SqlData/Application/Cqrs/Group/Queries/GetGroupDetails/GetGroupInfoQuery.cs similarity index 100% rename from Application/Cqrs/Group/Queries/GetGroupDetails/GetGroupInfoQuery.cs rename to SqlData/Application/Cqrs/Group/Queries/GetGroupDetails/GetGroupInfoQuery.cs diff --git a/Application/Cqrs/Group/Queries/GetGroupDetails/GetGroupInfoQueryHandler.cs b/SqlData/Application/Cqrs/Group/Queries/GetGroupDetails/GetGroupInfoQueryHandler.cs similarity index 100% rename from Application/Cqrs/Group/Queries/GetGroupDetails/GetGroupInfoQueryHandler.cs rename to SqlData/Application/Cqrs/Group/Queries/GetGroupDetails/GetGroupInfoQueryHandler.cs diff --git a/Application/Cqrs/Group/Queries/GetGroupDetails/GroupInfoVm.cs b/SqlData/Application/Cqrs/Group/Queries/GetGroupDetails/GroupInfoVm.cs similarity index 100% rename from Application/Cqrs/Group/Queries/GetGroupDetails/GroupInfoVm.cs rename to SqlData/Application/Cqrs/Group/Queries/GetGroupDetails/GroupInfoVm.cs diff --git a/Application/Cqrs/Group/Queries/GetGroupList/GetGroupListQuery.cs b/SqlData/Application/Cqrs/Group/Queries/GetGroupList/GetGroupListQuery.cs similarity index 100% rename from Application/Cqrs/Group/Queries/GetGroupList/GetGroupListQuery.cs rename to SqlData/Application/Cqrs/Group/Queries/GetGroupList/GetGroupListQuery.cs diff --git a/Application/Cqrs/Group/Queries/GetGroupList/GetGroupListQueryHandler.cs b/SqlData/Application/Cqrs/Group/Queries/GetGroupList/GetGroupListQueryHandler.cs similarity index 100% rename from Application/Cqrs/Group/Queries/GetGroupList/GetGroupListQueryHandler.cs rename to SqlData/Application/Cqrs/Group/Queries/GetGroupList/GetGroupListQueryHandler.cs diff --git a/Application/Cqrs/Group/Queries/GetGroupList/GroupListVm.cs b/SqlData/Application/Cqrs/Group/Queries/GetGroupList/GroupListVm.cs similarity index 100% rename from Application/Cqrs/Group/Queries/GetGroupList/GroupListVm.cs rename to SqlData/Application/Cqrs/Group/Queries/GetGroupList/GroupListVm.cs diff --git a/Application/Cqrs/Group/Queries/GetGroupList/GroupLookupDto.cs b/SqlData/Application/Cqrs/Group/Queries/GetGroupList/GroupLookupDto.cs similarity index 100% rename from Application/Cqrs/Group/Queries/GetGroupList/GroupLookupDto.cs rename to SqlData/Application/Cqrs/Group/Queries/GetGroupList/GroupLookupDto.cs diff --git a/Application/Cqrs/LectureHall/Queries/GetLectureHallDetails/GetLectureHallInfoQuery.cs b/SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallDetails/GetLectureHallInfoQuery.cs similarity index 100% rename from Application/Cqrs/LectureHall/Queries/GetLectureHallDetails/GetLectureHallInfoQuery.cs rename to SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallDetails/GetLectureHallInfoQuery.cs diff --git a/Application/Cqrs/LectureHall/Queries/GetLectureHallDetails/GetLectureHallInfoQueryHandler.cs b/SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallDetails/GetLectureHallInfoQueryHandler.cs similarity index 100% rename from Application/Cqrs/LectureHall/Queries/GetLectureHallDetails/GetLectureHallInfoQueryHandler.cs rename to SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallDetails/GetLectureHallInfoQueryHandler.cs diff --git a/Application/Cqrs/LectureHall/Queries/GetLectureHallDetails/LectureHallInfoVm.cs b/SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallDetails/LectureHallInfoVm.cs similarity index 100% rename from Application/Cqrs/LectureHall/Queries/GetLectureHallDetails/LectureHallInfoVm.cs rename to SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallDetails/LectureHallInfoVm.cs diff --git a/Application/Cqrs/LectureHall/Queries/GetLectureHallList/GetLectureHallListQuery.cs b/SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallList/GetLectureHallListQuery.cs similarity index 100% rename from Application/Cqrs/LectureHall/Queries/GetLectureHallList/GetLectureHallListQuery.cs rename to SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallList/GetLectureHallListQuery.cs diff --git a/Application/Cqrs/LectureHall/Queries/GetLectureHallList/GetLectureHallListQueryHandler.cs b/SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallList/GetLectureHallListQueryHandler.cs similarity index 100% rename from Application/Cqrs/LectureHall/Queries/GetLectureHallList/GetLectureHallListQueryHandler.cs rename to SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallList/GetLectureHallListQueryHandler.cs diff --git a/Application/Cqrs/LectureHall/Queries/GetLectureHallList/LectureHallListVm.cs b/SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallList/LectureHallListVm.cs similarity index 100% rename from Application/Cqrs/LectureHall/Queries/GetLectureHallList/LectureHallListVm.cs rename to SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallList/LectureHallListVm.cs diff --git a/Application/Cqrs/LectureHall/Queries/GetLectureHallList/LectureHallLookupDto.cs b/SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallList/LectureHallLookupDto.cs similarity index 100% rename from Application/Cqrs/LectureHall/Queries/GetLectureHallList/LectureHallLookupDto.cs rename to SqlData/Application/Cqrs/LectureHall/Queries/GetLectureHallList/LectureHallLookupDto.cs diff --git a/Application/Cqrs/Professor/Queries/GetProfessorDetails/GetProfessorInfoQuery.cs b/SqlData/Application/Cqrs/Professor/Queries/GetProfessorDetails/GetProfessorInfoQuery.cs similarity index 100% rename from Application/Cqrs/Professor/Queries/GetProfessorDetails/GetProfessorInfoQuery.cs rename to SqlData/Application/Cqrs/Professor/Queries/GetProfessorDetails/GetProfessorInfoQuery.cs diff --git a/Application/Cqrs/Professor/Queries/GetProfessorDetails/GetProfessorInfoQueryHandler.cs b/SqlData/Application/Cqrs/Professor/Queries/GetProfessorDetails/GetProfessorInfoQueryHandler.cs similarity index 100% rename from Application/Cqrs/Professor/Queries/GetProfessorDetails/GetProfessorInfoQueryHandler.cs rename to SqlData/Application/Cqrs/Professor/Queries/GetProfessorDetails/GetProfessorInfoQueryHandler.cs diff --git a/Application/Cqrs/Professor/Queries/GetProfessorDetails/ProfessorInfoVm.cs b/SqlData/Application/Cqrs/Professor/Queries/GetProfessorDetails/ProfessorInfoVm.cs similarity index 100% rename from Application/Cqrs/Professor/Queries/GetProfessorDetails/ProfessorInfoVm.cs rename to SqlData/Application/Cqrs/Professor/Queries/GetProfessorDetails/ProfessorInfoVm.cs diff --git a/Application/Cqrs/Professor/Queries/GetProfessorList/GetProfessorListQuery.cs b/SqlData/Application/Cqrs/Professor/Queries/GetProfessorList/GetProfessorListQuery.cs similarity index 100% rename from Application/Cqrs/Professor/Queries/GetProfessorList/GetProfessorListQuery.cs rename to SqlData/Application/Cqrs/Professor/Queries/GetProfessorList/GetProfessorListQuery.cs diff --git a/Application/Cqrs/Professor/Queries/GetProfessorList/GetProfessorListQueryHandler.cs b/SqlData/Application/Cqrs/Professor/Queries/GetProfessorList/GetProfessorListQueryHandler.cs similarity index 100% rename from Application/Cqrs/Professor/Queries/GetProfessorList/GetProfessorListQueryHandler.cs rename to SqlData/Application/Cqrs/Professor/Queries/GetProfessorList/GetProfessorListQueryHandler.cs diff --git a/Application/Cqrs/Professor/Queries/GetProfessorList/ProfessorListVm.cs b/SqlData/Application/Cqrs/Professor/Queries/GetProfessorList/ProfessorListVm.cs similarity index 100% rename from Application/Cqrs/Professor/Queries/GetProfessorList/ProfessorListVm.cs rename to SqlData/Application/Cqrs/Professor/Queries/GetProfessorList/ProfessorListVm.cs diff --git a/Application/Cqrs/Professor/Queries/GetProfessorList/ProfessorLookupDto.cs b/SqlData/Application/Cqrs/Professor/Queries/GetProfessorList/ProfessorLookupDto.cs similarity index 100% rename from Application/Cqrs/Professor/Queries/GetProfessorList/ProfessorLookupDto.cs rename to SqlData/Application/Cqrs/Professor/Queries/GetProfessorList/ProfessorLookupDto.cs diff --git a/Application/Cqrs/Schedule/Queries/GetScheduleList/GetScheduleListQuery.cs b/SqlData/Application/Cqrs/Schedule/Queries/GetScheduleList/GetScheduleListQuery.cs similarity index 100% rename from Application/Cqrs/Schedule/Queries/GetScheduleList/GetScheduleListQuery.cs rename to SqlData/Application/Cqrs/Schedule/Queries/GetScheduleList/GetScheduleListQuery.cs diff --git a/Application/Cqrs/Schedule/Queries/GetScheduleList/GetScheduleListQueryHandler.cs b/SqlData/Application/Cqrs/Schedule/Queries/GetScheduleList/GetScheduleListQueryHandler.cs similarity index 100% rename from Application/Cqrs/Schedule/Queries/GetScheduleList/GetScheduleListQueryHandler.cs rename to SqlData/Application/Cqrs/Schedule/Queries/GetScheduleList/GetScheduleListQueryHandler.cs diff --git a/Application/Cqrs/Schedule/Queries/GetScheduleList/ScheduleListVm.cs b/SqlData/Application/Cqrs/Schedule/Queries/GetScheduleList/ScheduleListVm.cs similarity index 100% rename from Application/Cqrs/Schedule/Queries/GetScheduleList/ScheduleListVm.cs rename to SqlData/Application/Cqrs/Schedule/Queries/GetScheduleList/ScheduleListVm.cs diff --git a/Application/Cqrs/Schedule/Queries/GetScheduleList/ScheduleLookupDto.cs b/SqlData/Application/Cqrs/Schedule/Queries/GetScheduleList/ScheduleLookupDto.cs similarity index 100% rename from Application/Cqrs/Schedule/Queries/GetScheduleList/ScheduleLookupDto.cs rename to SqlData/Application/Cqrs/Schedule/Queries/GetScheduleList/ScheduleLookupDto.cs diff --git a/Application/DependencyInjection.cs b/SqlData/Application/DependencyInjection.cs similarity index 100% rename from Application/DependencyInjection.cs rename to SqlData/Application/DependencyInjection.cs diff --git a/Application/Interfaces/DbContexts/IDbContextBase.cs b/SqlData/Application/Interfaces/DbContexts/IDbContextBase.cs similarity index 100% rename from Application/Interfaces/DbContexts/IDbContextBase.cs rename to SqlData/Application/Interfaces/DbContexts/IDbContextBase.cs diff --git a/Application/Interfaces/DbContexts/Schedule/ICampusDbContext.cs b/SqlData/Application/Interfaces/DbContexts/Schedule/ICampusDbContext.cs similarity index 100% rename from Application/Interfaces/DbContexts/Schedule/ICampusDbContext.cs rename to SqlData/Application/Interfaces/DbContexts/Schedule/ICampusDbContext.cs diff --git a/Application/Interfaces/DbContexts/Schedule/IDisciplineDbContext.cs b/SqlData/Application/Interfaces/DbContexts/Schedule/IDisciplineDbContext.cs similarity index 100% rename from Application/Interfaces/DbContexts/Schedule/IDisciplineDbContext.cs rename to SqlData/Application/Interfaces/DbContexts/Schedule/IDisciplineDbContext.cs diff --git a/Application/Interfaces/DbContexts/Schedule/IFacultyDbContext.cs b/SqlData/Application/Interfaces/DbContexts/Schedule/IFacultyDbContext.cs similarity index 100% rename from Application/Interfaces/DbContexts/Schedule/IFacultyDbContext.cs rename to SqlData/Application/Interfaces/DbContexts/Schedule/IFacultyDbContext.cs diff --git a/Application/Interfaces/DbContexts/Schedule/IGroupDbContext.cs b/SqlData/Application/Interfaces/DbContexts/Schedule/IGroupDbContext.cs similarity index 100% rename from Application/Interfaces/DbContexts/Schedule/IGroupDbContext.cs rename to SqlData/Application/Interfaces/DbContexts/Schedule/IGroupDbContext.cs diff --git a/Application/Interfaces/DbContexts/Schedule/ILectureHallDbContext.cs b/SqlData/Application/Interfaces/DbContexts/Schedule/ILectureHallDbContext.cs similarity index 100% rename from Application/Interfaces/DbContexts/Schedule/ILectureHallDbContext.cs rename to SqlData/Application/Interfaces/DbContexts/Schedule/ILectureHallDbContext.cs diff --git a/Application/Interfaces/DbContexts/Schedule/ILessonAssociationDbContext.cs b/SqlData/Application/Interfaces/DbContexts/Schedule/ILessonAssociationDbContext.cs similarity index 100% rename from Application/Interfaces/DbContexts/Schedule/ILessonAssociationDbContext.cs rename to SqlData/Application/Interfaces/DbContexts/Schedule/ILessonAssociationDbContext.cs diff --git a/Application/Interfaces/DbContexts/Schedule/ILessonDbContext.cs b/SqlData/Application/Interfaces/DbContexts/Schedule/ILessonDbContext.cs similarity index 100% rename from Application/Interfaces/DbContexts/Schedule/ILessonDbContext.cs rename to SqlData/Application/Interfaces/DbContexts/Schedule/ILessonDbContext.cs diff --git a/Application/Interfaces/DbContexts/Schedule/IProfessorDbContext.cs b/SqlData/Application/Interfaces/DbContexts/Schedule/IProfessorDbContext.cs similarity index 100% rename from Application/Interfaces/DbContexts/Schedule/IProfessorDbContext.cs rename to SqlData/Application/Interfaces/DbContexts/Schedule/IProfessorDbContext.cs diff --git a/Application/Interfaces/DbContexts/Schedule/ISpecificWeekDbContext.cs b/SqlData/Application/Interfaces/DbContexts/Schedule/ISpecificWeekDbContext.cs similarity index 100% rename from Application/Interfaces/DbContexts/Schedule/ISpecificWeekDbContext.cs rename to SqlData/Application/Interfaces/DbContexts/Schedule/ISpecificWeekDbContext.cs diff --git a/Application/Interfaces/DbContexts/Schedule/ITypeOfOccupationDbContext.cs b/SqlData/Application/Interfaces/DbContexts/Schedule/ITypeOfOccupationDbContext.cs similarity index 100% rename from Application/Interfaces/DbContexts/Schedule/ITypeOfOccupationDbContext.cs rename to SqlData/Application/Interfaces/DbContexts/Schedule/ITypeOfOccupationDbContext.cs diff --git a/Domain/Domain.csproj b/SqlData/Domain/Domain.csproj similarity index 100% rename from Domain/Domain.csproj rename to SqlData/Domain/Domain.csproj diff --git a/Domain/Schedule/Campus.cs b/SqlData/Domain/Schedule/Campus.cs similarity index 100% rename from Domain/Schedule/Campus.cs rename to SqlData/Domain/Schedule/Campus.cs diff --git a/Domain/Schedule/Discipline.cs b/SqlData/Domain/Schedule/Discipline.cs similarity index 100% rename from Domain/Schedule/Discipline.cs rename to SqlData/Domain/Schedule/Discipline.cs diff --git a/Domain/Schedule/Faculty.cs b/SqlData/Domain/Schedule/Faculty.cs similarity index 100% rename from Domain/Schedule/Faculty.cs rename to SqlData/Domain/Schedule/Faculty.cs diff --git a/Domain/Schedule/Group.cs b/SqlData/Domain/Schedule/Group.cs similarity index 100% rename from Domain/Schedule/Group.cs rename to SqlData/Domain/Schedule/Group.cs diff --git a/Domain/Schedule/LectureHall.cs b/SqlData/Domain/Schedule/LectureHall.cs similarity index 100% rename from Domain/Schedule/LectureHall.cs rename to SqlData/Domain/Schedule/LectureHall.cs diff --git a/Domain/Schedule/Lesson.cs b/SqlData/Domain/Schedule/Lesson.cs similarity index 100% rename from Domain/Schedule/Lesson.cs rename to SqlData/Domain/Schedule/Lesson.cs diff --git a/Domain/Schedule/LessonAssociation.cs b/SqlData/Domain/Schedule/LessonAssociation.cs similarity index 100% rename from Domain/Schedule/LessonAssociation.cs rename to SqlData/Domain/Schedule/LessonAssociation.cs diff --git a/Domain/Schedule/Professor.cs b/SqlData/Domain/Schedule/Professor.cs similarity index 100% rename from Domain/Schedule/Professor.cs rename to SqlData/Domain/Schedule/Professor.cs diff --git a/Domain/Schedule/SpecificWeek.cs b/SqlData/Domain/Schedule/SpecificWeek.cs similarity index 100% rename from Domain/Schedule/SpecificWeek.cs rename to SqlData/Domain/Schedule/SpecificWeek.cs diff --git a/Domain/Schedule/TypeOfOccupation.cs b/SqlData/Domain/Schedule/TypeOfOccupation.cs similarity index 100% rename from Domain/Schedule/TypeOfOccupation.cs rename to SqlData/Domain/Schedule/TypeOfOccupation.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/MysqlMigrations/MysqlMigrations.csproj b/SqlData/Migrations/MysqlMigrations/MysqlMigrations.csproj new file mode 100644 index 0000000..d9d83f2 --- /dev/null +++ b/SqlData/Migrations/MysqlMigrations/MysqlMigrations.csproj @@ -0,0 +1,12 @@ + + + + net8.0 + ..\..\Persistence\bin\ + + + + + + + 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/PsqlMigrations/PsqlMigrations.csproj b/SqlData/Migrations/PsqlMigrations/PsqlMigrations.csproj new file mode 100644 index 0000000..d9d83f2 --- /dev/null +++ b/SqlData/Migrations/PsqlMigrations/PsqlMigrations.csproj @@ -0,0 +1,12 @@ + + + + net8.0 + ..\..\Persistence\bin\ + + + + + + + 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 + } + } +} diff --git a/SqlData/Migrations/SqliteMigrations/SqliteMigrations.csproj b/SqlData/Migrations/SqliteMigrations/SqliteMigrations.csproj new file mode 100644 index 0000000..d9d83f2 --- /dev/null +++ b/SqlData/Migrations/SqliteMigrations/SqliteMigrations.csproj @@ -0,0 +1,12 @@ + + + + net8.0 + ..\..\Persistence\bin\ + + + + + + + diff --git a/SqlData/Persistence/Common/BaseDbContext.cs b/SqlData/Persistence/Common/BaseDbContext.cs new file mode 100644 index 0000000..c3dd911 --- /dev/null +++ b/SqlData/Persistence/Common/BaseDbContext.cs @@ -0,0 +1,9 @@ +using Microsoft.EntityFrameworkCore; + +namespace Mirea.Api.DataAccess.Persistence.Common; + +public abstract class BaseDbContext(DbContextOptions options) : DbContext(options) where TContext : DbContext +{ + public void ApplyConfigurations(ModelBuilder modelBuilder) => + base.OnModelCreating(modelBuilder); +} \ No newline at end of file diff --git a/SqlData/Persistence/Common/ConfigurationResolver.cs b/SqlData/Persistence/Common/ConfigurationResolver.cs new file mode 100644 index 0000000..907b8ca --- /dev/null +++ b/SqlData/Persistence/Common/ConfigurationResolver.cs @@ -0,0 +1,23 @@ +using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations; +using System; +using System.Linq; +using System.Reflection; + +namespace Mirea.Api.DataAccess.Persistence.Common; + +public static class ConfigurationResolver +{ + public static Type GetConfigurationType(DatabaseProvider provider) + where TEntity : class + { + var entityType = typeof(TEntity); + var providerNamespace = typeof(Mark).Namespace + "." + Enum.GetName(provider); + + var assembly = Assembly.GetExecutingAssembly(); + var configurationType = assembly.GetTypes() + .FirstOrDefault(t => t.Namespace != null && t.Namespace.StartsWith(providerNamespace) && t.Name == $"{entityType.Name}Configuration"); + + return configurationType ?? + throw new InvalidOperationException($"Configuration type not found for entity {entityType.Name} and provider {provider}."); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/Common/DatabaseProvider.cs b/SqlData/Persistence/Common/DatabaseProvider.cs new file mode 100644 index 0000000..c3d15cf --- /dev/null +++ b/SqlData/Persistence/Common/DatabaseProvider.cs @@ -0,0 +1,8 @@ +namespace Mirea.Api.DataAccess.Persistence.Common; + +public enum DatabaseProvider +{ + Mysql, + Sqlite, + Postgresql +} \ No newline at end of file diff --git a/SqlData/Persistence/Common/DbContextFactory.cs b/SqlData/Persistence/Common/DbContextFactory.cs new file mode 100644 index 0000000..d8ea52d --- /dev/null +++ b/SqlData/Persistence/Common/DbContextFactory.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; +using System; + +namespace Mirea.Api.DataAccess.Persistence.Common; + +public static class DbContextFactory +{ + public static DbContextOptionsBuilder CreateDbContext(this DbContextOptionsBuilder options, DatabaseProvider provider) + where TDbContext : BaseDbContext + where TEntity : class + { + var dbContext = (TDbContext)Activator.CreateInstance(typeof(TDbContext), (DbContextOptions)options.Options)!; + var configurationType = ConfigurationResolver.GetConfigurationType(provider); + var configurationInstance = (IEntityTypeConfiguration)Activator.CreateInstance(configurationType)!; + + var modelBuilder = new ModelBuilder(); + modelBuilder.ApplyConfiguration(configurationInstance); + dbContext.ApplyConfigurations(modelBuilder); + + return options; + } +} \ No newline at end of file diff --git a/SqlData/Persistence/Common/ModelBuilderExtensions.cs b/SqlData/Persistence/Common/ModelBuilderExtensions.cs new file mode 100644 index 0000000..2198808 --- /dev/null +++ b/SqlData/Persistence/Common/ModelBuilderExtensions.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; +using System.Linq; + +namespace Mirea.Api.DataAccess.Persistence.Common; + +public static class ModelBuilderExtensions +{ + public static void ApplyConfiguration(this ModelBuilder modelBuilder, object configuration) + { + var applyGenericMethod = typeof(ModelBuilder) + .GetMethods() + .First(m => m.Name == "ApplyConfiguration" && + m.GetParameters().Any(p => p.ParameterType.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>))); + + var entityType = configuration.GetType().GetInterfaces() + .First(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>)) + .GetGenericArguments()[0]; + + var applyConcreteMethod = applyGenericMethod.MakeGenericMethod(entityType); + applyConcreteMethod.Invoke(modelBuilder, [configuration]); + } +} diff --git a/Persistence/Contexts/Schedule/CampusDbContext.cs b/SqlData/Persistence/Contexts/Schedule/CampusDbContext.cs similarity index 67% rename from Persistence/Contexts/Schedule/CampusDbContext.cs rename to SqlData/Persistence/Contexts/Schedule/CampusDbContext.cs index 30a9d56..d93e3d9 100644 --- a/Persistence/Contexts/Schedule/CampusDbContext.cs +++ b/SqlData/Persistence/Contexts/Schedule/CampusDbContext.cs @@ -1,17 +1,18 @@ using Microsoft.EntityFrameworkCore; using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; using Mirea.Api.DataAccess.Domain.Schedule; -using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +using Mirea.Api.DataAccess.Persistence.Common; +using System.Reflection; namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule; -public class CampusDbContext(DbContextOptions options) : DbContext(options), ICampusDbContext +public class CampusDbContext(DbContextOptions options) : BaseDbContext(options), ICampusDbContext { public DbSet Campuses { get; set; } = null!; protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.ApplyConfiguration(new CampusConfiguration()); + modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/Persistence/Contexts/Schedule/DisciplineDbContext.cs b/SqlData/Persistence/Contexts/Schedule/DisciplineDbContext.cs similarity index 56% rename from Persistence/Contexts/Schedule/DisciplineDbContext.cs rename to SqlData/Persistence/Contexts/Schedule/DisciplineDbContext.cs index d0a5612..d9ec9e1 100644 --- a/Persistence/Contexts/Schedule/DisciplineDbContext.cs +++ b/SqlData/Persistence/Contexts/Schedule/DisciplineDbContext.cs @@ -1,17 +1,18 @@ using Microsoft.EntityFrameworkCore; using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; using Mirea.Api.DataAccess.Domain.Schedule; -using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +using Mirea.Api.DataAccess.Persistence.Common; +using System.Reflection; namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule; -public class DisciplineDbContext(DbContextOptions options) : DbContext(options), IDisciplineDbContext +public sealed class DisciplineDbContext(DbContextOptions options) : BaseDbContext(options), IDisciplineDbContext { public DbSet Disciplines { get; set; } = null!; protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.ApplyConfiguration(new DisciplineConfiguration()); + modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/Persistence/Contexts/Schedule/FacultyDbContext.cs b/SqlData/Persistence/Contexts/Schedule/FacultyDbContext.cs similarity index 57% rename from Persistence/Contexts/Schedule/FacultyDbContext.cs rename to SqlData/Persistence/Contexts/Schedule/FacultyDbContext.cs index ab6a45c..98323a6 100644 --- a/Persistence/Contexts/Schedule/FacultyDbContext.cs +++ b/SqlData/Persistence/Contexts/Schedule/FacultyDbContext.cs @@ -1,17 +1,18 @@ using Microsoft.EntityFrameworkCore; using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; using Mirea.Api.DataAccess.Domain.Schedule; -using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +using Mirea.Api.DataAccess.Persistence.Common; +using System.Reflection; namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule; -public class FacultyDbContext(DbContextOptions options) : DbContext(options), IFacultyDbContext +public sealed class FacultyDbContext(DbContextOptions options) : BaseDbContext(options), IFacultyDbContext { public DbSet Faculties { get; set; } = null!; protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.ApplyConfiguration(new FacultyConfiguration()); + modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/Persistence/Contexts/Schedule/GroupDbContext.cs b/SqlData/Persistence/Contexts/Schedule/GroupDbContext.cs similarity index 57% rename from Persistence/Contexts/Schedule/GroupDbContext.cs rename to SqlData/Persistence/Contexts/Schedule/GroupDbContext.cs index 5d61c70..e6bcc5e 100644 --- a/Persistence/Contexts/Schedule/GroupDbContext.cs +++ b/SqlData/Persistence/Contexts/Schedule/GroupDbContext.cs @@ -1,17 +1,18 @@ using Microsoft.EntityFrameworkCore; using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; using Mirea.Api.DataAccess.Domain.Schedule; -using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +using Mirea.Api.DataAccess.Persistence.Common; +using System.Reflection; namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule; -public class GroupDbContext(DbContextOptions options) : DbContext(options), IGroupDbContext +public sealed class GroupDbContext(DbContextOptions options) : BaseDbContext(options), IGroupDbContext { public DbSet Groups { get; set; } = null!; protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.ApplyConfiguration(new GroupConfiguration()); + modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/Persistence/Contexts/Schedule/LectureHallDbContext.cs b/SqlData/Persistence/Contexts/Schedule/LectureHallDbContext.cs similarity index 56% rename from Persistence/Contexts/Schedule/LectureHallDbContext.cs rename to SqlData/Persistence/Contexts/Schedule/LectureHallDbContext.cs index 67841a1..4253309 100644 --- a/Persistence/Contexts/Schedule/LectureHallDbContext.cs +++ b/SqlData/Persistence/Contexts/Schedule/LectureHallDbContext.cs @@ -1,17 +1,18 @@ using Microsoft.EntityFrameworkCore; using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; using Mirea.Api.DataAccess.Domain.Schedule; -using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +using Mirea.Api.DataAccess.Persistence.Common; +using System.Reflection; namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule; -public class LectureHallDbContext(DbContextOptions options) : DbContext(options), ILectureHallDbContext +public sealed class LectureHallDbContext(DbContextOptions options) : BaseDbContext(options), ILectureHallDbContext { public DbSet LectureHalls { get; set; } = null!; protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.ApplyConfiguration(new LectureHallConfiguration()); + modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/Persistence/Contexts/Schedule/LessonAssociationDbContext.cs b/SqlData/Persistence/Contexts/Schedule/LessonAssociationDbContext.cs similarity index 55% rename from Persistence/Contexts/Schedule/LessonAssociationDbContext.cs rename to SqlData/Persistence/Contexts/Schedule/LessonAssociationDbContext.cs index 773bc8a..ae6be39 100644 --- a/Persistence/Contexts/Schedule/LessonAssociationDbContext.cs +++ b/SqlData/Persistence/Contexts/Schedule/LessonAssociationDbContext.cs @@ -1,17 +1,18 @@ using Microsoft.EntityFrameworkCore; using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; using Mirea.Api.DataAccess.Domain.Schedule; -using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +using Mirea.Api.DataAccess.Persistence.Common; +using System.Reflection; namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule; -public class LessonAssociationDbContext(DbContextOptions options) : DbContext(options), ILessonAssociationDbContext +public sealed class LessonAssociationDbContext(DbContextOptions options) : BaseDbContext(options), ILessonAssociationDbContext { public DbSet LessonAssociations { get; set; } = null!; protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.ApplyConfiguration(new LessonAssociationConfiguration()); + modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/Persistence/Contexts/Schedule/LessonDbContext.cs b/SqlData/Persistence/Contexts/Schedule/LessonDbContext.cs similarity index 57% rename from Persistence/Contexts/Schedule/LessonDbContext.cs rename to SqlData/Persistence/Contexts/Schedule/LessonDbContext.cs index d2dfcae..e727041 100644 --- a/Persistence/Contexts/Schedule/LessonDbContext.cs +++ b/SqlData/Persistence/Contexts/Schedule/LessonDbContext.cs @@ -1,17 +1,18 @@ using Microsoft.EntityFrameworkCore; using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; using Mirea.Api.DataAccess.Domain.Schedule; -using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +using Mirea.Api.DataAccess.Persistence.Common; +using System.Reflection; namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule; -public class LessonDbContext(DbContextOptions options) : DbContext(options), ILessonDbContext +public sealed class LessonDbContext(DbContextOptions options) : BaseDbContext(options), ILessonDbContext { public DbSet Lessons { get; set; } = null!; protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.ApplyConfiguration(new LessonConfiguration()); + modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/Persistence/Contexts/Schedule/ProfessorDbContext.cs b/SqlData/Persistence/Contexts/Schedule/ProfessorDbContext.cs similarity index 56% rename from Persistence/Contexts/Schedule/ProfessorDbContext.cs rename to SqlData/Persistence/Contexts/Schedule/ProfessorDbContext.cs index fcd51c6..75924ff 100644 --- a/Persistence/Contexts/Schedule/ProfessorDbContext.cs +++ b/SqlData/Persistence/Contexts/Schedule/ProfessorDbContext.cs @@ -1,17 +1,18 @@ using Microsoft.EntityFrameworkCore; using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; using Mirea.Api.DataAccess.Domain.Schedule; -using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +using Mirea.Api.DataAccess.Persistence.Common; +using System.Reflection; namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule; -public class ProfessorDbContext(DbContextOptions options) : DbContext(options), IProfessorDbContext +public sealed class ProfessorDbContext(DbContextOptions options) : BaseDbContext(options), IProfessorDbContext { public DbSet Professors { get; set; } = null!; protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.ApplyConfiguration(new ProfessorConfiguration()); + modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/Persistence/Contexts/Schedule/SpecificWeekDbContext.cs b/SqlData/Persistence/Contexts/Schedule/SpecificWeekDbContext.cs similarity index 56% rename from Persistence/Contexts/Schedule/SpecificWeekDbContext.cs rename to SqlData/Persistence/Contexts/Schedule/SpecificWeekDbContext.cs index b3601bd..20bbab7 100644 --- a/Persistence/Contexts/Schedule/SpecificWeekDbContext.cs +++ b/SqlData/Persistence/Contexts/Schedule/SpecificWeekDbContext.cs @@ -1,17 +1,18 @@ using Microsoft.EntityFrameworkCore; using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; using Mirea.Api.DataAccess.Domain.Schedule; -using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +using Mirea.Api.DataAccess.Persistence.Common; +using System.Reflection; namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule; -public class SpecificWeekDbContext(DbContextOptions options) : DbContext(options), ISpecificWeekDbContext +public sealed class SpecificWeekDbContext(DbContextOptions options) : BaseDbContext(options), ISpecificWeekDbContext { public DbSet SpecificWeeks { get; set; } = null!; protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.ApplyConfiguration(new SpecificWeekConfiguration()); + modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/Persistence/Contexts/Schedule/TypeOfOccupationDbContext.cs b/SqlData/Persistence/Contexts/Schedule/TypeOfOccupationDbContext.cs similarity index 55% rename from Persistence/Contexts/Schedule/TypeOfOccupationDbContext.cs rename to SqlData/Persistence/Contexts/Schedule/TypeOfOccupationDbContext.cs index b47ac61..ae49d35 100644 --- a/Persistence/Contexts/Schedule/TypeOfOccupationDbContext.cs +++ b/SqlData/Persistence/Contexts/Schedule/TypeOfOccupationDbContext.cs @@ -1,17 +1,18 @@ using Microsoft.EntityFrameworkCore; using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; using Mirea.Api.DataAccess.Domain.Schedule; -using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +using Mirea.Api.DataAccess.Persistence.Common; +using System.Reflection; namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule; -public class TypeOfOccupationDbContext(DbContextOptions options) : DbContext(options), ITypeOfOccupationDbContext +public sealed class TypeOfOccupationDbContext(DbContextOptions options) : BaseDbContext(options), ITypeOfOccupationDbContext { public DbSet TypeOfOccupations { get; set; } = null!; protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.ApplyConfiguration(new TypeOfOccupationConfiguration()); + modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/Persistence/DbInitializer.cs b/SqlData/Persistence/DbInitializer.cs similarity index 80% rename from Persistence/DbInitializer.cs rename to SqlData/Persistence/DbInitializer.cs index 87f3a9b..7bedd91 100644 --- a/Persistence/DbInitializer.cs +++ b/SqlData/Persistence/DbInitializer.cs @@ -6,6 +6,6 @@ public static class DbInitializer { public static void Initialize(DbContext dbContext) { - dbContext.Database.EnsureCreated(); + dbContext.Database.Migrate(); } } \ No newline at end of file diff --git a/SqlData/Persistence/DependencyInjection.cs b/SqlData/Persistence/DependencyInjection.cs new file mode 100644 index 0000000..f86cd87 --- /dev/null +++ b/SqlData/Persistence/DependencyInjection.cs @@ -0,0 +1,89 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; +using Mirea.Api.DataAccess.Domain.Schedule; +using Mirea.Api.DataAccess.Persistence.Common; +using Mirea.Api.DataAccess.Persistence.Contexts.Schedule; +using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations; +using System; +using System.Linq; +using System.Reflection; + +namespace Mirea.Api.DataAccess.Persistence; + +public static class DependencyInjection +{ + public static IServiceCollection AddPersistence(this IServiceCollection services, DatabaseProvider dbProvider, string connection) + { + services.AddDbContext(options => + UseDatabase(options).CreateDbContext(dbProvider)); + services.AddDbContext(options => + UseDatabase(options).CreateDbContext(dbProvider)); + services.AddDbContext(options => + UseDatabase(options).CreateDbContext(dbProvider)); + services.AddDbContext(options => + UseDatabase(options).CreateDbContext(dbProvider)); + services.AddDbContext(options => + UseDatabase(options).CreateDbContext(dbProvider)); + services.AddDbContext(options => + UseDatabase(options).CreateDbContext(dbProvider)); + services.AddDbContext(options => + UseDatabase(options).CreateDbContext(dbProvider)); + services.AddDbContext(options => + UseDatabase(options).CreateDbContext(dbProvider)); + services.AddDbContext(options => + UseDatabase(options).CreateDbContext(dbProvider)); + services.AddDbContext(options => + UseDatabase(options).CreateDbContext(dbProvider)); + + services.AddDbContext(options => + { + var providerNamespace = typeof(Mark).Namespace + "." + Enum.GetName(dbProvider); + + var assembly = Assembly.GetExecutingAssembly(); + var configurationTypes = assembly.GetTypes() + .Where(t => + t is { IsNested: false, IsAbstract: false, Namespace: not null } && + t.Namespace.StartsWith(providerNamespace) && + t.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>))); + + var modelBuilder = new ModelBuilder(); + + foreach (var configurationType in configurationTypes) + { + var configurationInstance = Activator.CreateInstance(configurationType)!; + modelBuilder.ApplyConfiguration(configurationInstance); + } + + var dbContext = (UberDbContext)Activator.CreateInstance(typeof(UberDbContext), (DbContextOptions)UseDatabase(options).Options)!; + dbContext.ApplyConfigurations(modelBuilder); + }); + + services.AddScoped(provider => provider.GetRequiredService()); + services.AddScoped(provider => provider.GetRequiredService()); + services.AddScoped(provider => provider.GetRequiredService()); + services.AddScoped(provider => provider.GetRequiredService()); + services.AddScoped(provider => provider.GetRequiredService()); + services.AddScoped(provider => provider.GetRequiredService()); + services.AddScoped(provider => provider.GetRequiredService()); + services.AddScoped(provider => provider.GetRequiredService()); + services.AddScoped(provider => provider.GetRequiredService()); + services.AddScoped(provider => provider.GetRequiredService()); + + return services; + + DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder options) + { + return dbProvider switch + { + DatabaseProvider.Mysql => options.UseMySql(connection, ServerVersion.AutoDetect(connection), + x => x.MigrationsAssembly("MysqlMigrations")), + DatabaseProvider.Sqlite => options.UseSqlite(connection, + x => x.MigrationsAssembly("SqliteMigrations")), + DatabaseProvider.Postgresql => options.UseNpgsql(connection, + x => x.MigrationsAssembly("PsqlMigrations")), + _ => throw new ArgumentException("Unsupported database provider", Enum.GetName(dbProvider)) + }; + } + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Mark.cs b/SqlData/Persistence/EntityTypeConfigurations/Mark.cs new file mode 100644 index 0000000..734dd03 --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Mark.cs @@ -0,0 +1,3 @@ +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations; + +public sealed class Mark; \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/CampusConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/CampusConfiguration.cs new file mode 100644 index 0000000..a6a961d --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/CampusConfiguration.cs @@ -0,0 +1,20 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.Schedule; + +public sealed class CampusConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(Campus)); + builder.HasKey(c => c.Id); + builder.HasIndex(c => c.Id).IsUnique(); + builder.Property(c => c.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(c => c.Address).HasColumnType("VARCHAR(512)").HasMaxLength(512); + builder.Property(c => c.CodeName).HasColumnType("VARCHAR(16)").IsRequired().HasMaxLength(16); + builder.Property(c => c.FullName).HasColumnType("VARCHAR(256)").HasMaxLength(256); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/DisciplineConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/DisciplineConfiguration.cs new file mode 100644 index 0000000..ababf1f --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/DisciplineConfiguration.cs @@ -0,0 +1,18 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.Schedule; + +public class DisciplineConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(Discipline)); + builder.HasKey(d => d.Id); + builder.HasIndex(d => d.Id).IsUnique(); + builder.Property(d => d.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(d => d.Name).HasColumnType("VARCHAR(256)").HasMaxLength(256).IsRequired(); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/FacultyConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/FacultyConfiguration.cs new file mode 100644 index 0000000..3e2e24d --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/FacultyConfiguration.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.Schedule; + +public class FacultyConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(Faculty)); + builder.HasKey(f => f.Id); + builder.HasIndex(f => f.Id).IsUnique(); + 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/Mysql/Schedule/GroupConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/GroupConfiguration.cs new file mode 100644 index 0000000..a0e1645 --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/GroupConfiguration.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.Schedule; + +public class GroupConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(Group)); + builder.HasKey(g => g.Id); + builder.HasIndex(g => g.Id).IsUnique(); + builder.Property(g => g.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(g => g.FacultyId).HasColumnType("INT"); + builder.Property(g => g.Name).HasColumnType("VARCHAR(64)").IsRequired().HasMaxLength(64); + + builder + .HasOne(g => g.Faculty) + .WithMany(u => u.Groups) + .HasForeignKey(d => d.FacultyId) + .OnDelete(DeleteBehavior.SetNull); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/LectureHallConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/LectureHallConfiguration.cs new file mode 100644 index 0000000..ec9ab8c --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/LectureHallConfiguration.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.Schedule; + +public class LectureHallConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(LectureHall)); + builder.HasKey(l => l.Id); + builder.HasIndex(l => l.Id).IsUnique(); + builder.Property(l => l.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(l => l.CampusId).HasColumnType("INT").IsRequired(); + builder.Property(l => l.Name).HasColumnType("VARCHAR(64)").IsRequired().HasMaxLength(64); + + builder + .HasOne(l => l.Campus) + .WithMany(c => c.LectureHalls) + .HasForeignKey(d => d.CampusId) + .OnDelete(DeleteBehavior.Restrict); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/LessonAssociationConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/LessonAssociationConfiguration.cs new file mode 100644 index 0000000..f35317d --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/LessonAssociationConfiguration.cs @@ -0,0 +1,48 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.Schedule; + +public class LessonAssociationConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(LessonAssociation)); + builder.HasKey(l => l.Id); + builder.HasIndex(l => l.Id).IsUnique(); + builder.Property(l => l.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(l => l.LinkToMeet).HasColumnType("VARCHAR(512)").HasMaxLength(512); + + builder.Property(l => l.LessonId).HasColumnType("INT").IsRequired(); + builder.Property(l => l.ProfessorId).HasColumnType("INT"); + builder.Property(l => l.LectureHallId).HasColumnType("INT"); + builder.Property(l => l.TypeOfOccupationId).HasColumnType("INT").IsRequired(); + + + builder + .HasOne(l => l.Lesson) + .WithMany(d => d.LessonAssociations) + .HasForeignKey(l => l.LessonId) + .OnDelete(DeleteBehavior.Cascade); + + builder + .HasOne(l => l.Professor) + .WithMany(p => p.LessonAssociations) + .HasForeignKey(l => l.ProfessorId) + .OnDelete(DeleteBehavior.SetNull); + + builder + .HasOne(l => l.LectureHall) + .WithMany(l => l.LessonAssociations) + .HasForeignKey(l => l.LectureHallId) + .OnDelete(DeleteBehavior.SetNull); + + builder + .HasOne(l => l.TypeOfOccupation) + .WithMany(t => t.Lessons) + .HasForeignKey(d => d.TypeOfOccupationId) + .OnDelete(DeleteBehavior.Cascade); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/LessonConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/LessonConfiguration.cs new file mode 100644 index 0000000..66e76d8 --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/LessonConfiguration.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.Schedule; + +public class LessonConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(Lesson)); + builder.HasKey(l => l.Id); + builder.HasIndex(l => l.Id).IsUnique(); + builder.Property(l => l.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(l => l.IsEven).HasColumnType("BIT(1)").IsRequired(); + builder.Property(l => l.DayOfWeek).HasColumnType("INT").IsRequired(); + builder.Property(l => l.PairNumber).HasColumnType("INT").IsRequired(); + builder.Property(l => l.IsExcludedWeeks).HasColumnType("BIT(1)"); + + builder.Property(l => l.GroupId).HasColumnType("INT").IsRequired(); + builder.Property(l => l.DisciplineId).HasColumnType("INT").IsRequired(); + + builder + .HasOne(l => l.Group) + .WithMany(g => g.Lessons) + .HasForeignKey(d => d.GroupId) + .OnDelete(DeleteBehavior.Cascade); + + builder + .HasOne(l => l.Discipline) + .WithMany(d => d.Lessons) + .HasForeignKey(l => l.DisciplineId) + .OnDelete(DeleteBehavior.Cascade); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/ProfessorConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/ProfessorConfiguration.cs new file mode 100644 index 0000000..a7e8f02 --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/ProfessorConfiguration.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.Schedule; + +public class ProfessorConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(Professor)); + builder.HasKey(p => p.Id); + builder.HasIndex(p => p.Id).IsUnique(); + builder.Property(p => p.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(p => p.Name).HasColumnType("VARCHAR").IsRequired(); + builder.Property(p => p.AltName).HasColumnType("VARCHAR"); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/SpecificWeekConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/SpecificWeekConfiguration.cs new file mode 100644 index 0000000..e7b0529 --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/SpecificWeekConfiguration.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.Schedule; + +public class SpecificWeekConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(SpecificWeek)); + builder.HasKey(s => s.Id); + builder.HasIndex(s => s.Id).IsUnique(); + builder.Property(s => s.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(s => s.WeekNumber).HasColumnType("INT").IsRequired(); + + builder.Property(s => s.LessonId).HasColumnType("INT").IsRequired(); + + builder + .HasOne(s => s.Lesson) + .WithMany(l => l.SpecificWeeks) + .HasForeignKey(s => s.LessonId) + .OnDelete(DeleteBehavior.Cascade); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/TypeOfOccupationConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/TypeOfOccupationConfiguration.cs new file mode 100644 index 0000000..90e92e5 --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Mysql/Schedule/TypeOfOccupationConfiguration.cs @@ -0,0 +1,18 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Mysql.Schedule; + +public class TypeOfOccupationConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(TypeOfOccupation)); + builder.HasKey(t => t.Id); + builder.HasIndex(t => t.Id).IsUnique(); + builder.Property(t => t.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(t => t.ShortName).HasColumnType("VARCHAR").IsRequired().HasMaxLength(16); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/CampusConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/CampusConfiguration.cs new file mode 100644 index 0000000..055be55 --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/CampusConfiguration.cs @@ -0,0 +1,20 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Postgresql.Schedule; + +public sealed class CampusConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(Campus)); + builder.HasKey(c => c.Id); + builder.HasIndex(c => c.Id).IsUnique(); + builder.Property(c => c.Id).HasColumnType("serial").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(c => c.Address).HasColumnType("text").HasMaxLength(512); + builder.Property(c => c.CodeName).HasColumnType("text").IsRequired().HasMaxLength(16); + builder.Property(c => c.FullName).HasColumnType("text").HasMaxLength(256); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/DisciplineConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/DisciplineConfiguration.cs new file mode 100644 index 0000000..01ff876 --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/DisciplineConfiguration.cs @@ -0,0 +1,18 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Postgresql.Schedule; + +public class DisciplineConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(Discipline)); + builder.HasKey(d => d.Id); + builder.HasIndex(d => d.Id).IsUnique(); + builder.Property(d => d.Id).HasColumnType("serial").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(d => d.Name).HasColumnType("text").HasMaxLength(256).IsRequired(); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/FacultyConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/FacultyConfiguration.cs new file mode 100644 index 0000000..05f622f --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/FacultyConfiguration.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Postgresql.Schedule; + +public class FacultyConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(Faculty)); + builder.HasKey(f => f.Id); + builder.HasIndex(f => f.Id).IsUnique(); + 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/Postgresql/Schedule/GroupConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/GroupConfiguration.cs new file mode 100644 index 0000000..1ee501d --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/GroupConfiguration.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Postgresql.Schedule; + +public class GroupConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(Group)); + builder.HasKey(g => g.Id); + builder.HasIndex(g => g.Id).IsUnique(); + builder.Property(g => g.Id).HasColumnType("serial").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(g => g.FacultyId).HasColumnType("serial"); + builder.Property(g => g.Name).HasColumnType("text").IsRequired().HasMaxLength(64); + + builder + .HasOne(g => g.Faculty) + .WithMany(u => u.Groups) + .HasForeignKey(d => d.FacultyId) + .OnDelete(DeleteBehavior.SetNull); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/LectureHallConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/LectureHallConfiguration.cs new file mode 100644 index 0000000..039df3d --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/LectureHallConfiguration.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Postgresql.Schedule; + +public class LectureHallConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(LectureHall)); + builder.HasKey(l => l.Id); + builder.HasIndex(l => l.Id).IsUnique(); + builder.Property(l => l.Id).HasColumnType("INT").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(l => l.CampusId).HasColumnType("INT").IsRequired(); + builder.Property(l => l.Name).HasColumnType("VARCHAR(64)").IsRequired().HasMaxLength(64); + + builder + .HasOne(l => l.Campus) + .WithMany(c => c.LectureHalls) + .HasForeignKey(d => d.CampusId) + .OnDelete(DeleteBehavior.Restrict); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/LessonAssociationConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/LessonAssociationConfiguration.cs new file mode 100644 index 0000000..aef538a --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/LessonAssociationConfiguration.cs @@ -0,0 +1,48 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Postgresql.Schedule; + +public class LessonAssociationConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(LessonAssociation)); + builder.HasKey(l => l.Id); + builder.HasIndex(l => l.Id).IsUnique(); + builder.Property(l => l.Id).HasColumnType("serial").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(l => l.LinkToMeet).HasColumnType("text").HasMaxLength(512); + + builder.Property(l => l.LessonId).HasColumnType("serial").IsRequired(); + builder.Property(l => l.ProfessorId).HasColumnType("serial"); + builder.Property(l => l.LectureHallId).HasColumnType("serial"); + builder.Property(l => l.TypeOfOccupationId).HasColumnType("serial").IsRequired(); + + + builder + .HasOne(l => l.Lesson) + .WithMany(d => d.LessonAssociations) + .HasForeignKey(l => l.LessonId) + .OnDelete(DeleteBehavior.Cascade); + + builder + .HasOne(l => l.Professor) + .WithMany(p => p.LessonAssociations) + .HasForeignKey(l => l.ProfessorId) + .OnDelete(DeleteBehavior.SetNull); + + builder + .HasOne(l => l.LectureHall) + .WithMany(l => l.LessonAssociations) + .HasForeignKey(l => l.LectureHallId) + .OnDelete(DeleteBehavior.SetNull); + + builder + .HasOne(l => l.TypeOfOccupation) + .WithMany(t => t.Lessons) + .HasForeignKey(d => d.TypeOfOccupationId) + .OnDelete(DeleteBehavior.Cascade); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/LessonConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/LessonConfiguration.cs new file mode 100644 index 0000000..a47076d --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/LessonConfiguration.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Postgresql.Schedule; + +public class LessonConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(Lesson)); + builder.HasKey(l => l.Id); + builder.HasIndex(l => l.Id).IsUnique(); + builder.Property(l => l.Id).HasColumnType("serial").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(l => l.IsEven).HasColumnType("boolean").IsRequired(); + builder.Property(l => l.DayOfWeek).HasColumnType("serial").IsRequired(); + builder.Property(l => l.PairNumber).HasColumnType("serial").IsRequired(); + builder.Property(l => l.IsExcludedWeeks).HasColumnType("boolean"); + + builder.Property(l => l.GroupId).HasColumnType("serial").IsRequired(); + builder.Property(l => l.DisciplineId).HasColumnType("serial").IsRequired(); + + builder + .HasOne(l => l.Group) + .WithMany(g => g.Lessons) + .HasForeignKey(d => d.GroupId) + .OnDelete(DeleteBehavior.Cascade); + + builder + .HasOne(l => l.Discipline) + .WithMany(d => d.Lessons) + .HasForeignKey(l => l.DisciplineId) + .OnDelete(DeleteBehavior.Cascade); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/ProfessorConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/ProfessorConfiguration.cs new file mode 100644 index 0000000..9779cde --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/ProfessorConfiguration.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Postgresql.Schedule; + +public class ProfessorConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(Professor)); + builder.HasKey(p => p.Id); + builder.HasIndex(p => p.Id).IsUnique(); + builder.Property(p => p.Id).HasColumnType("serial").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(p => p.Name).HasColumnType("text").IsRequired(); + builder.Property(p => p.AltName).HasColumnType("text"); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/SpecificWeekConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/SpecificWeekConfiguration.cs new file mode 100644 index 0000000..6415c7b --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/SpecificWeekConfiguration.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Postgresql.Schedule; + +public class SpecificWeekConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(SpecificWeek)); + builder.HasKey(s => s.Id); + builder.HasIndex(s => s.Id).IsUnique(); + builder.Property(s => s.Id).HasColumnType("serial").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(s => s.WeekNumber).HasColumnType("serial").IsRequired(); + + builder.Property(s => s.LessonId).HasColumnType("serial").IsRequired(); + + builder + .HasOne(s => s.Lesson) + .WithMany(l => l.SpecificWeeks) + .HasForeignKey(s => s.LessonId) + .OnDelete(DeleteBehavior.Cascade); + } +} \ No newline at end of file diff --git a/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/TypeOfOccupationConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/TypeOfOccupationConfiguration.cs new file mode 100644 index 0000000..af53715 --- /dev/null +++ b/SqlData/Persistence/EntityTypeConfigurations/Postgresql/Schedule/TypeOfOccupationConfiguration.cs @@ -0,0 +1,18 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Mirea.Api.DataAccess.Domain.Schedule; + +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Postgresql.Schedule; + +public class TypeOfOccupationConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable(nameof(TypeOfOccupation)); + builder.HasKey(t => t.Id); + builder.HasIndex(t => t.Id).IsUnique(); + builder.Property(t => t.Id).HasColumnType("serial").IsRequired().ValueGeneratedOnAdd(); + + builder.Property(t => t.ShortName).HasColumnType("text").IsRequired().HasMaxLength(16); + } +} \ No newline at end of file diff --git a/Persistence/EntityTypeConfigurations/Schedule/CampusConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/CampusConfiguration.cs similarity index 88% rename from Persistence/EntityTypeConfigurations/Schedule/CampusConfiguration.cs rename to SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/CampusConfiguration.cs index 410d6c2..3a85a0a 100644 --- a/Persistence/EntityTypeConfigurations/Schedule/CampusConfiguration.cs +++ b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/CampusConfiguration.cs @@ -2,9 +2,9 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Mirea.Api.DataAccess.Domain.Schedule; -namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule; -public class CampusConfiguration : IEntityTypeConfiguration +public sealed class CampusConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { diff --git a/Persistence/EntityTypeConfigurations/Schedule/DisciplineConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/DisciplineConfiguration.cs similarity index 96% rename from Persistence/EntityTypeConfigurations/Schedule/DisciplineConfiguration.cs rename to SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/DisciplineConfiguration.cs index f92ac02..94356f8 100644 --- a/Persistence/EntityTypeConfigurations/Schedule/DisciplineConfiguration.cs +++ b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/DisciplineConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Mirea.Api.DataAccess.Domain.Schedule; -namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule; public class DisciplineConfiguration : IEntityTypeConfiguration { diff --git a/Persistence/EntityTypeConfigurations/Schedule/FacultyConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/FacultyConfiguration.cs similarity index 97% rename from Persistence/EntityTypeConfigurations/Schedule/FacultyConfiguration.cs rename to SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/FacultyConfiguration.cs index d61fce5..c7cde69 100644 --- a/Persistence/EntityTypeConfigurations/Schedule/FacultyConfiguration.cs +++ b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/FacultyConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Mirea.Api.DataAccess.Domain.Schedule; -namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule; public class FacultyConfiguration : IEntityTypeConfiguration { diff --git a/Persistence/EntityTypeConfigurations/Schedule/GroupConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/GroupConfiguration.cs similarity index 97% rename from Persistence/EntityTypeConfigurations/Schedule/GroupConfiguration.cs rename to SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/GroupConfiguration.cs index 5938bb3..e4b49d0 100644 --- a/Persistence/EntityTypeConfigurations/Schedule/GroupConfiguration.cs +++ b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/GroupConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Mirea.Api.DataAccess.Domain.Schedule; -namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule; public class GroupConfiguration : IEntityTypeConfiguration { diff --git a/Persistence/EntityTypeConfigurations/Schedule/LectureHallConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/LectureHallConfiguration.cs similarity index 97% rename from Persistence/EntityTypeConfigurations/Schedule/LectureHallConfiguration.cs rename to SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/LectureHallConfiguration.cs index 2d10805..1896d55 100644 --- a/Persistence/EntityTypeConfigurations/Schedule/LectureHallConfiguration.cs +++ b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/LectureHallConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Mirea.Api.DataAccess.Domain.Schedule; -namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule; public class LectureHallConfiguration : IEntityTypeConfiguration { diff --git a/Persistence/EntityTypeConfigurations/Schedule/LessonAssociationConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/LessonAssociationConfiguration.cs similarity index 98% rename from Persistence/EntityTypeConfigurations/Schedule/LessonAssociationConfiguration.cs rename to SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/LessonAssociationConfiguration.cs index c9ecb8c..65fb513 100644 --- a/Persistence/EntityTypeConfigurations/Schedule/LessonAssociationConfiguration.cs +++ b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/LessonAssociationConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Mirea.Api.DataAccess.Domain.Schedule; -namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule; public class LessonAssociationConfiguration : IEntityTypeConfiguration { diff --git a/Persistence/EntityTypeConfigurations/Schedule/LessonConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/LessonConfiguration.cs similarity index 98% rename from Persistence/EntityTypeConfigurations/Schedule/LessonConfiguration.cs rename to SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/LessonConfiguration.cs index 8d9c8cd..099c7d6 100644 --- a/Persistence/EntityTypeConfigurations/Schedule/LessonConfiguration.cs +++ b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/LessonConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Mirea.Api.DataAccess.Domain.Schedule; -namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule; public class LessonConfiguration : IEntityTypeConfiguration { diff --git a/Persistence/EntityTypeConfigurations/Schedule/ProfessorConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/ProfessorConfiguration.cs similarity index 97% rename from Persistence/EntityTypeConfigurations/Schedule/ProfessorConfiguration.cs rename to SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/ProfessorConfiguration.cs index 7b95ab8..37352cc 100644 --- a/Persistence/EntityTypeConfigurations/Schedule/ProfessorConfiguration.cs +++ b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/ProfessorConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Mirea.Api.DataAccess.Domain.Schedule; -namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule; public class ProfessorConfiguration : IEntityTypeConfiguration { diff --git a/Persistence/EntityTypeConfigurations/Schedule/SpecificWeekConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/SpecificWeekConfiguration.cs similarity index 97% rename from Persistence/EntityTypeConfigurations/Schedule/SpecificWeekConfiguration.cs rename to SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/SpecificWeekConfiguration.cs index f4fc8a3..cdab80d 100644 --- a/Persistence/EntityTypeConfigurations/Schedule/SpecificWeekConfiguration.cs +++ b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/SpecificWeekConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Mirea.Api.DataAccess.Domain.Schedule; -namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule; public class SpecificWeekConfiguration : IEntityTypeConfiguration { diff --git a/Persistence/EntityTypeConfigurations/Schedule/TypeOfOccupationConfiguration.cs b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/TypeOfOccupationConfiguration.cs similarity index 96% rename from Persistence/EntityTypeConfigurations/Schedule/TypeOfOccupationConfiguration.cs rename to SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/TypeOfOccupationConfiguration.cs index 5341a5a..6d7a2da 100644 --- a/Persistence/EntityTypeConfigurations/Schedule/TypeOfOccupationConfiguration.cs +++ b/SqlData/Persistence/EntityTypeConfigurations/Sqlite/Schedule/TypeOfOccupationConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Mirea.Api.DataAccess.Domain.Schedule; -namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule; public class TypeOfOccupationConfiguration : IEntityTypeConfiguration { diff --git a/Persistence/Persistence.csproj b/SqlData/Persistence/Persistence.csproj similarity index 85% rename from Persistence/Persistence.csproj rename to SqlData/Persistence/Persistence.csproj index 37f0a7f..07ca710 100644 --- a/Persistence/Persistence.csproj +++ b/SqlData/Persistence/Persistence.csproj @@ -13,11 +13,11 @@ - - + + - - + + @@ -25,8 +25,4 @@ - - - - \ No newline at end of file diff --git a/Persistence/UberDbContext.cs b/SqlData/Persistence/UberDbContext.cs similarity index 54% rename from Persistence/UberDbContext.cs rename to SqlData/Persistence/UberDbContext.cs index ccd1877..3777ef2 100644 --- a/Persistence/UberDbContext.cs +++ b/SqlData/Persistence/UberDbContext.cs @@ -1,10 +1,11 @@ using Microsoft.EntityFrameworkCore; using Mirea.Api.DataAccess.Domain.Schedule; -using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule; +using Mirea.Api.DataAccess.Persistence.Common; +using System.Reflection; namespace Mirea.Api.DataAccess.Persistence; -public class UberDbContext(DbContextOptions options) : DbContext(options) +public class UberDbContext(DbContextOptions options) : BaseDbContext(options) { public DbSet Campuses { get; set; } = null!; public DbSet Disciplines { get; set; } = null!; @@ -19,17 +20,7 @@ public class UberDbContext(DbContextOptions options) : DbContext( protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.ApplyConfiguration(new CampusConfiguration()); - modelBuilder.ApplyConfiguration(new DisciplineConfiguration()); - modelBuilder.ApplyConfiguration(new FacultyConfiguration()); - modelBuilder.ApplyConfiguration(new GroupConfiguration()); - modelBuilder.ApplyConfiguration(new LectureHallConfiguration()); - modelBuilder.ApplyConfiguration(new LessonConfiguration()); - modelBuilder.ApplyConfiguration(new ProfessorConfiguration()); - modelBuilder.ApplyConfiguration(new LessonAssociationConfiguration()); - modelBuilder.ApplyConfiguration(new TypeOfOccupationConfiguration()); - modelBuilder.ApplyConfiguration(new SpecificWeekConfiguration()); - + modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); base.OnModelCreating(modelBuilder); } } \ No newline at end of file