From 0d316be670067437f83bdfd47c817e7495327aaf Mon Sep 17 00:00:00 2001 From: cuqmbr Date: Wed, 15 Nov 2023 18:59:57 +0200 Subject: [PATCH] merged infrastructure and persistence projects --- .../Data/ApplicationDbContext.cs | 71 ++++++++ .../Configurations/AddressConfiguration.cs | 2 +- .../Configurations/AircraftConfiguration.cs | 2 +- .../Data}/Configurations/BusConfiguration.cs | 2 +- .../Configurations/CarriageConfiguration.cs | 2 +- .../Data}/Configurations/CityConfiguration.cs | 2 +- .../Configurations/CompanyConfiguration.cs | 2 +- .../Configurations/CountryConfiguration.cs | 2 +- .../Configurations/EmployeeConfiguration.cs | 12 +- .../EmployeeDocumentConfiguration.cs | 2 +- .../Configurations/EntityBaseConfiguration.cs | 2 +- .../Configurations/RegionConfiguration.cs | 2 +- .../Configurations/ReviewConfiguration.cs | 4 +- .../RouteAddressConfiguration.cs | 2 +- .../RouteAddressDetailsConfiguration.cs | 2 +- .../Configurations/RouteConfiguration.cs | 2 +- .../Configurations/TicketConfiguration.cs | 2 +- .../TicketDocumentConfiguration.cs | 2 +- .../TicketGroupConfiguraions.cs | 4 +- .../TrainCarriageConfiguration.cs | 2 +- .../Configurations/TrainConfiguration.cs | 2 +- .../Data}/Configurations/UserConfiguration.cs | 14 +- .../Configurations/VehicleConfiguration.cs | 2 +- .../VehicleEnrollmentConfiguration.cs | 4 +- .../VehicleEnrollmentEmployeeConfiguration.cs | 2 +- .../Data}/Entities/Coordinates.cs | 2 +- .../20231113193110_InitialCreate.Designer.cs | 77 ++++---- .../20231113193110_InitialCreate.cs | 167 +++++++++++++++--- .../ApplicationDbContextModelSnapshot.cs | 75 ++++---- .../AutobusApi.Persistence.csproj | 26 --- .../Contexts/PostgresContext.cs | 64 ------- AutobusApi.sln | 5 - 32 files changed, 350 insertions(+), 213 deletions(-) create mode 100644 AutobusApi.Infrastructure/Data/ApplicationDbContext.cs rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/AddressConfiguration.cs (96%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/AircraftConfiguration.cs (96%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/BusConfiguration.cs (97%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/CarriageConfiguration.cs (96%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/CityConfiguration.cs (94%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/CompanyConfiguration.cs (95%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/CountryConfiguration.cs (92%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/EmployeeConfiguration.cs (87%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/EmployeeDocumentConfiguration.cs (96%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/EntityBaseConfiguration.cs (92%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/RegionConfiguration.cs (95%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/ReviewConfiguration.cs (94%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/RouteAddressConfiguration.cs (96%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/RouteAddressDetailsConfiguration.cs (97%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/RouteConfiguration.cs (92%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/TicketConfiguration.cs (95%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/TicketDocumentConfiguration.cs (96%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/TicketGroupConfiguraions.cs (97%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/TrainCarriageConfiguration.cs (95%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/TrainConfiguration.cs (94%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/UserConfiguration.cs (65%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/VehicleConfiguration.cs (94%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/VehicleEnrollmentConfiguration.cs (95%) rename {AutobusApi.Persistence/Contexts => AutobusApi.Infrastructure/Data}/Configurations/VehicleEnrollmentEmployeeConfiguration.cs (96%) rename {AutobusApi.Persistence => AutobusApi.Infrastructure/Data}/Entities/Coordinates.cs (87%) rename AutobusApi.Persistence/Migrations/20231101122211_initial_create.Designer.cs => AutobusApi.Infrastructure/Data/Migrations/20231113193110_InitialCreate.Designer.cs (95%) rename AutobusApi.Persistence/Migrations/20231101122211_initial_create.cs => AutobusApi.Infrastructure/Data/Migrations/20231113193110_InitialCreate.cs (86%) rename AutobusApi.Persistence/Migrations/PostgresContextModelSnapshot.cs => AutobusApi.Infrastructure/Data/Migrations/ApplicationDbContextModelSnapshot.cs (95%) delete mode 100644 AutobusApi.Persistence/AutobusApi.Persistence.csproj delete mode 100644 AutobusApi.Persistence/Contexts/PostgresContext.cs diff --git a/AutobusApi.Infrastructure/Data/ApplicationDbContext.cs b/AutobusApi.Infrastructure/Data/ApplicationDbContext.cs new file mode 100644 index 0000000..6072d37 --- /dev/null +++ b/AutobusApi.Infrastructure/Data/ApplicationDbContext.cs @@ -0,0 +1,71 @@ +using System.Reflection; +using AutobusApi.Application.Common.Interfaces; +using AutobusApi.Domain.Entities; +using Microsoft.EntityFrameworkCore; + +namespace AutoubsApi.Infrastructure.Data; + +public class ApplicationDbContext : DbContext, IApplicationDbContext +{ + public ApplicationDbContext(DbContextOptions options) : base(options) { } + + public DbSet Countries { get => Set(); } + + public DbSet Regions { get => Set(); } + + public DbSet Cities { get => Set(); } + + public DbSet
Addresses { get => Set
(); } + + public DbSet RouteAddresses { get => Set(); } + + public DbSet Routes { get => Set(); } + + public DbSet RouteAddressDetails { get => Set(); } + + public DbSet VehicleEnrollments { get => Set(); } + + public DbSet Vehicles { get => Set(); } + + public DbSet Buses { get => Set(); } + + public DbSet Aircraft { get => Set(); } + + public DbSet Trains { get => Set(); } + + public DbSet TrainCarriages { get => Set(); } + + public DbSet Carriages { get => Set(); } + + public DbSet Companies { get => Set(); } + + public DbSet Employees { get => Set(); } + + public DbSet EmployeeDocuments { get => Set(); } + + public DbSet vehicleEnrollmentEmployees { get => Set(); } + + public DbSet ApplicationUsers { get => Set(); } + + public DbSet TicketGroups { get => Set(); } + + public DbSet Tickets { get => Set(); } + + public DbSet TicketDocuments { get => Set(); } + + public DbSet Reviews { get => Set(); } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + builder.HasPostgresExtension("postgis"); + + builder.HasDefaultSchema("domain"); + + builder.ApplyConfigurationsFromAssembly( + Assembly.GetExecutingAssembly(), + t => t.Namespace == "AutobusApi.Infrastructure.Data.Configurations" + ); + } +} diff --git a/AutobusApi.Persistence/Contexts/Configurations/AddressConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/AddressConfiguration.cs similarity index 96% rename from AutobusApi.Persistence/Contexts/Configurations/AddressConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/AddressConfiguration.cs index 059d5e6..8a6581d 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/AddressConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/AddressConfiguration.cs @@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using NetTopologySuite.Geometries; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class AddressConfiguration : EntityBaseConfiguration
{ diff --git a/AutobusApi.Persistence/Contexts/Configurations/AircraftConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/AircraftConfiguration.cs similarity index 96% rename from AutobusApi.Persistence/Contexts/Configurations/AircraftConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/AircraftConfiguration.cs index 03a8958..fd5cee0 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/AircraftConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/AircraftConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class AircraftConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/BusConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/BusConfiguration.cs similarity index 97% rename from AutobusApi.Persistence/Contexts/Configurations/BusConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/BusConfiguration.cs index ed831b5..416280c 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/BusConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/BusConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class BusConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/CarriageConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/CarriageConfiguration.cs similarity index 96% rename from AutobusApi.Persistence/Contexts/Configurations/CarriageConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/CarriageConfiguration.cs index 2952857..08fab05 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/CarriageConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/CarriageConfiguration.cs @@ -3,7 +3,7 @@ using AutobusApi.Domain.Enums; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class CarriageConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/CityConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/CityConfiguration.cs similarity index 94% rename from AutobusApi.Persistence/Contexts/Configurations/CityConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/CityConfiguration.cs index ff55a52..36ceaaf 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/CityConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/CityConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class CityConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/CompanyConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/CompanyConfiguration.cs similarity index 95% rename from AutobusApi.Persistence/Contexts/Configurations/CompanyConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/CompanyConfiguration.cs index f560fde..cef4842 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/CompanyConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/CompanyConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class CompanyConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/CountryConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/CountryConfiguration.cs similarity index 92% rename from AutobusApi.Persistence/Contexts/Configurations/CountryConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/CountryConfiguration.cs index 9fcc5a0..9c682c9 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/CountryConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/CountryConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class CountryConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/EmployeeConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/EmployeeConfiguration.cs similarity index 87% rename from AutobusApi.Persistence/Contexts/Configurations/EmployeeConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/EmployeeConfiguration.cs index 6c47f4d..2247427 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/EmployeeConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/EmployeeConfiguration.cs @@ -3,7 +3,7 @@ using AutobusApi.Domain.Enums; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class EmployeeConfiguration : EntityBaseConfiguration { @@ -49,6 +49,16 @@ public class EmployeeConfiguration : EntityBaseConfiguration .HasColumnType("date") .IsRequired(); + builder + .Property(e => e.IdentityId) + .HasColumnName("identity_id") + .HasColumnType("int") + .IsRequired(); + + builder + .HasIndex(e => e.IdentityId) + .IsUnique(); + builder .Property(e => e.EmployerCompanyId) .HasColumnName("employer_company_id") diff --git a/AutobusApi.Persistence/Contexts/Configurations/EmployeeDocumentConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/EmployeeDocumentConfiguration.cs similarity index 96% rename from AutobusApi.Persistence/Contexts/Configurations/EmployeeDocumentConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/EmployeeDocumentConfiguration.cs index db5b34b..a3c7021 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/EmployeeDocumentConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/EmployeeDocumentConfiguration.cs @@ -3,7 +3,7 @@ using AutobusApi.Domain.Enums; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class EmployeeDocumentConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/EntityBaseConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/EntityBaseConfiguration.cs similarity index 92% rename from AutobusApi.Persistence/Contexts/Configurations/EntityBaseConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/EntityBaseConfiguration.cs index cc86b1d..6ec33cc 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/EntityBaseConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/EntityBaseConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Common; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class EntityBaseConfiguration : IEntityTypeConfiguration where TEntity : EntityBase diff --git a/AutobusApi.Persistence/Contexts/Configurations/RegionConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/RegionConfiguration.cs similarity index 95% rename from AutobusApi.Persistence/Contexts/Configurations/RegionConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/RegionConfiguration.cs index 9f9deee..fc9351a 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/RegionConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/RegionConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class RegionConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/ReviewConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/ReviewConfiguration.cs similarity index 94% rename from AutobusApi.Persistence/Contexts/Configurations/ReviewConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/ReviewConfiguration.cs index 0986db1..43eb646 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/ReviewConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/ReviewConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class ReviewConfiguration : EntityBaseConfiguration { @@ -29,7 +29,7 @@ public class ReviewConfiguration : EntityBaseConfiguration builder .Property(r => r.PostDateTimeUtc) .HasColumnName("post_timestamp_utc") - .HasColumnType("timestamp") + .HasColumnType("timestamptz") .IsRequired(); builder diff --git a/AutobusApi.Persistence/Contexts/Configurations/RouteAddressConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/RouteAddressConfiguration.cs similarity index 96% rename from AutobusApi.Persistence/Contexts/Configurations/RouteAddressConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/RouteAddressConfiguration.cs index d7e1491..023e25d 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/RouteAddressConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/RouteAddressConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class RouteAddressConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/RouteAddressDetailsConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/RouteAddressDetailsConfiguration.cs similarity index 97% rename from AutobusApi.Persistence/Contexts/Configurations/RouteAddressDetailsConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/RouteAddressDetailsConfiguration.cs index 7f4d8fb..54f110f 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/RouteAddressDetailsConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/RouteAddressDetailsConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class RouteAddressDeatilsConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/RouteConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/RouteConfiguration.cs similarity index 92% rename from AutobusApi.Persistence/Contexts/Configurations/RouteConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/RouteConfiguration.cs index 73d2505..dd2ca61 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/RouteConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/RouteConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class RouteConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/TicketConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/TicketConfiguration.cs similarity index 95% rename from AutobusApi.Persistence/Contexts/Configurations/TicketConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/TicketConfiguration.cs index 9e0002a..702e502 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/TicketConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/TicketConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class TicketConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/TicketDocumentConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/TicketDocumentConfiguration.cs similarity index 96% rename from AutobusApi.Persistence/Contexts/Configurations/TicketDocumentConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/TicketDocumentConfiguration.cs index 36ea420..3bdf4d9 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/TicketDocumentConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/TicketDocumentConfiguration.cs @@ -3,7 +3,7 @@ using AutobusApi.Domain.Enums; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class TicketDocumentConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/TicketGroupConfiguraions.cs b/AutobusApi.Infrastructure/Data/Configurations/TicketGroupConfiguraions.cs similarity index 97% rename from AutobusApi.Persistence/Contexts/Configurations/TicketGroupConfiguraions.cs rename to AutobusApi.Infrastructure/Data/Configurations/TicketGroupConfiguraions.cs index 7f1bb9b..7bf0f85 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/TicketGroupConfiguraions.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/TicketGroupConfiguraions.cs @@ -3,7 +3,7 @@ using AutobusApi.Domain.Enums; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class TicketGroupConfiguration : EntityBaseConfiguration { @@ -76,7 +76,7 @@ public class TicketGroupConfiguration : EntityBaseConfiguration builder .Property(tg => tg.PurchaseDateTimeUtc) .HasColumnName("purchase_timestamp_utc") - .HasColumnType("timestamp") + .HasColumnType("timestamptz") .IsRequired(); builder diff --git a/AutobusApi.Persistence/Contexts/Configurations/TrainCarriageConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/TrainCarriageConfiguration.cs similarity index 95% rename from AutobusApi.Persistence/Contexts/Configurations/TrainCarriageConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/TrainCarriageConfiguration.cs index 38922ca..051c729 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/TrainCarriageConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/TrainCarriageConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class TrainCarriageConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/TrainConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/TrainConfiguration.cs similarity index 94% rename from AutobusApi.Persistence/Contexts/Configurations/TrainConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/TrainConfiguration.cs index 830dce2..7cb55ee 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/TrainConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/TrainConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class TrainConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/UserConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/UserConfiguration.cs similarity index 65% rename from AutobusApi.Persistence/Contexts/Configurations/UserConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/UserConfiguration.cs index 573697d..6d0889c 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/UserConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/UserConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class UserConfiguration : EntityBaseConfiguration { @@ -12,7 +12,17 @@ public class UserConfiguration : EntityBaseConfiguration builder .ToTable("users") - .HasKey(e => e.Id); + .HasKey(u => u.Id); + + builder + .Property(u => u.IdentityId) + .HasColumnName("identity_id") + .HasColumnType("int") + .IsRequired(); + + builder + .HasIndex(u => u.IdentityId) + .IsUnique(); builder .HasMany(u => u.Reviews) diff --git a/AutobusApi.Persistence/Contexts/Configurations/VehicleConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/VehicleConfiguration.cs similarity index 94% rename from AutobusApi.Persistence/Contexts/Configurations/VehicleConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/VehicleConfiguration.cs index cf2ca53..aef7365 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/VehicleConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/VehicleConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class VehicleConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Contexts/Configurations/VehicleEnrollmentConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/VehicleEnrollmentConfiguration.cs similarity index 95% rename from AutobusApi.Persistence/Contexts/Configurations/VehicleEnrollmentConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/VehicleEnrollmentConfiguration.cs index 934775a..441dd07 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/VehicleEnrollmentConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/VehicleEnrollmentConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class VehicleEnrollmentConfiguration : EntityBaseConfiguration { @@ -17,7 +17,7 @@ public class VehicleEnrollmentConfiguration : EntityBaseConfiguration ve.DepartureDateTimeUtc) .HasColumnName("departure_timestamp_utc") - .HasColumnType("timestamp") + .HasColumnType("timestamptz") .IsRequired(); builder diff --git a/AutobusApi.Persistence/Contexts/Configurations/VehicleEnrollmentEmployeeConfiguration.cs b/AutobusApi.Infrastructure/Data/Configurations/VehicleEnrollmentEmployeeConfiguration.cs similarity index 96% rename from AutobusApi.Persistence/Contexts/Configurations/VehicleEnrollmentEmployeeConfiguration.cs rename to AutobusApi.Infrastructure/Data/Configurations/VehicleEnrollmentEmployeeConfiguration.cs index 0c4693b..8306c2d 100644 --- a/AutobusApi.Persistence/Contexts/Configurations/VehicleEnrollmentEmployeeConfiguration.cs +++ b/AutobusApi.Infrastructure/Data/Configurations/VehicleEnrollmentEmployeeConfiguration.cs @@ -2,7 +2,7 @@ using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AutobusApi.Persistence.Contexts.Configurations; +namespace AutobusApi.Infrastructure.Data.Configurations; public class VehicleEnrollmentEmployeeConfiguration : EntityBaseConfiguration { diff --git a/AutobusApi.Persistence/Entities/Coordinates.cs b/AutobusApi.Infrastructure/Data/Entities/Coordinates.cs similarity index 87% rename from AutobusApi.Persistence/Entities/Coordinates.cs rename to AutobusApi.Infrastructure/Data/Entities/Coordinates.cs index f649088..f7016d9 100644 --- a/AutobusApi.Persistence/Entities/Coordinates.cs +++ b/AutobusApi.Infrastructure/Data/Entities/Coordinates.cs @@ -1,7 +1,7 @@ using AutobusApi.Domain.IEntities; using NetTopologySuite.Geometries; -namespace AutobusApi.Persistence.Entities; +namespace AutobusApi.Infrastructure.Data.Entities; public class Coordinates : ICoordinates { diff --git a/AutobusApi.Persistence/Migrations/20231101122211_initial_create.Designer.cs b/AutobusApi.Infrastructure/Data/Migrations/20231113193110_InitialCreate.Designer.cs similarity index 95% rename from AutobusApi.Persistence/Migrations/20231101122211_initial_create.Designer.cs rename to AutobusApi.Infrastructure/Data/Migrations/20231113193110_InitialCreate.Designer.cs index 7ba0a4f..59f506e 100644 --- a/AutobusApi.Persistence/Migrations/20231101122211_initial_create.Designer.cs +++ b/AutobusApi.Infrastructure/Data/Migrations/20231113193110_InitialCreate.Designer.cs @@ -1,6 +1,6 @@ // using System; -using AutoubsApi.Persistence.Contexts; +using AutoubsApi.Infrastructure.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -10,17 +10,18 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable -namespace AutobusApi.Persistence.Migrations +namespace AutobusApi.Infrastructure.Data.Migrations { - [DbContext(typeof(PostgresContext))] - [Migration("20231101122211_initial_create")] - partial class initial_create + [DbContext(typeof(ApplicationDbContext))] + [Migration("20231113193110_InitialCreate")] + partial class InitialCreate { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder + .HasDefaultSchema("domain") .HasAnnotation("ProductVersion", "7.0.13") .HasAnnotation("Relational:MaxIdentifierLength", 63); @@ -63,7 +64,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("CityId"); - b.ToTable("addresses", (string)null); + b.ToTable("addresses", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Carriage", b => @@ -102,7 +103,7 @@ namespace AutobusApi.Persistence.Migrations b.HasKey("Id"); - b.ToTable("carriages", (string)null); + b.ToTable("carriages", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.City", b => @@ -131,7 +132,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("RegionId"); - b.ToTable("cities", (string)null); + b.ToTable("cities", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Company", b => @@ -169,7 +170,7 @@ namespace AutobusApi.Persistence.Migrations b.HasKey("Id"); - b.ToTable("companies", (string)null); + b.ToTable("companies", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Country", b => @@ -192,7 +193,7 @@ namespace AutobusApi.Persistence.Migrations b.HasKey("Id"); - b.ToTable("countries", (string)null); + b.ToTable("countries", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Employee", b => @@ -217,6 +218,10 @@ namespace AutobusApi.Persistence.Migrations .HasColumnType("varchar(32)") .HasColumnName("first_name"); + b.Property("IdentityId") + .HasColumnType("int") + .HasColumnName("identity_id"); + b.Property("IsDeleted") .HasColumnType("boolean") .HasColumnName("is_deleted"); @@ -240,7 +245,10 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("EmployerCompanyId"); - b.ToTable("employees", (string)null); + b.HasIndex("IdentityId") + .IsUnique(); + + b.ToTable("employees", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.EmployeeDocument", b => @@ -274,7 +282,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("EmployeeId"); - b.ToTable("employee_documents", (string)null); + b.ToTable("employee_documents", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Region", b => @@ -303,7 +311,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("CountryId"); - b.ToTable("regions", (string)null); + b.ToTable("regions", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Review", b => @@ -325,7 +333,7 @@ namespace AutobusApi.Persistence.Migrations .HasColumnName("is_deleted"); b.Property("PostDateTimeUtc") - .HasColumnType("timestamp") + .HasColumnType("timestamptz") .HasColumnName("post_timestamp_utc"); b.Property("Rating") @@ -346,7 +354,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("VehicleEnrollmentId"); - b.ToTable("reviews", (string)null); + b.ToTable("reviews", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Route", b => @@ -364,7 +372,7 @@ namespace AutobusApi.Persistence.Migrations b.HasKey("Id"); - b.ToTable("routes", (string)null); + b.ToTable("routes", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.RouteAddress", b => @@ -398,7 +406,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("RouteId"); - b.ToTable("route_addresses", (string)null); + b.ToTable("route_addresses", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.RouteAddressDetails", b => @@ -440,7 +448,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("VehicleEnrollmentId"); - b.ToTable("route_address_details", (string)null); + b.ToTable("route_address_details", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Ticket", b => @@ -470,7 +478,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("VehicleEnrollmentId"); - b.ToTable("tickets", (string)null); + b.ToTable("tickets", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.TicketDocument", b => @@ -502,7 +510,7 @@ namespace AutobusApi.Persistence.Migrations b.HasKey("Id"); - b.ToTable("ticket_documents", (string)null); + b.ToTable("ticket_documents", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.TicketGroup", b => @@ -567,7 +575,7 @@ namespace AutobusApi.Persistence.Migrations .HasColumnName("passenger_sex"); b.Property("PurchaseDateTimeUtc") - .HasColumnType("timestamp") + .HasColumnType("timestamptz") .HasColumnName("purchase_timestamp_utc"); b.Property("TicketDocumentId") @@ -584,7 +592,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("UserId"); - b.ToTable("ticket_groups", (string)null); + b.ToTable("ticket_groups", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.TrainCarriage", b => @@ -612,7 +620,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("TrainId"); - b.ToTable("train_carriages", (string)null); + b.ToTable("train_carriages", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.User", b => @@ -624,13 +632,20 @@ namespace AutobusApi.Persistence.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("IdentityId") + .HasColumnType("int") + .HasColumnName("identity_id"); + b.Property("IsDeleted") .HasColumnType("boolean") .HasColumnName("is_deleted"); b.HasKey("Id"); - b.ToTable("users", (string)null); + b.HasIndex("IdentityId") + .IsUnique(); + + b.ToTable("users", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Vehicle", b => @@ -654,7 +669,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("CompanyId"); - b.ToTable("vehicles", (string)null); + b.ToTable("vehicles", "domain"); b.UseTptMappingStrategy(); }); @@ -669,7 +684,7 @@ namespace AutobusApi.Persistence.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("DepartureDateTimeUtc") - .HasColumnType("timestamp") + .HasColumnType("timestamptz") .HasColumnName("departure_timestamp_utc"); b.Property("IsDeleted") @@ -690,7 +705,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("VehicleId"); - b.ToTable("vehicle_enrollments", (string)null); + b.ToTable("vehicle_enrollments", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.VehicleEnrollmentEmployee", b => @@ -720,7 +735,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("VehicleEnrollmentId"); - b.ToTable("vehicle_enrollment_employees", (string)null); + b.ToTable("vehicle_enrollment_employees", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Aircraft", b => @@ -749,7 +764,7 @@ namespace AutobusApi.Persistence.Migrations .HasColumnType("varchar(8)") .HasColumnName("number"); - b.ToTable("aircrafts", (string)null); + b.ToTable("aircrafts", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Bus", b => @@ -790,7 +805,7 @@ namespace AutobusApi.Persistence.Migrations .HasColumnType("varchar(8)") .HasColumnName("number"); - b.ToTable("buses", (string)null); + b.ToTable("buses", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Train", b => @@ -802,7 +817,7 @@ namespace AutobusApi.Persistence.Migrations .HasColumnType("varchar(8)") .HasColumnName("number"); - b.ToTable("trains", (string)null); + b.ToTable("trains", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Address", b => diff --git a/AutobusApi.Persistence/Migrations/20231101122211_initial_create.cs b/AutobusApi.Infrastructure/Data/Migrations/20231113193110_InitialCreate.cs similarity index 86% rename from AutobusApi.Persistence/Migrations/20231101122211_initial_create.cs rename to AutobusApi.Infrastructure/Data/Migrations/20231113193110_InitialCreate.cs index 2b98317..9730f46 100644 --- a/AutobusApi.Persistence/Migrations/20231101122211_initial_create.cs +++ b/AutobusApi.Infrastructure/Data/Migrations/20231113193110_InitialCreate.cs @@ -5,19 +5,23 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable -namespace AutobusApi.Persistence.Migrations +namespace AutobusApi.Infrastructure.Data.Migrations { /// - public partial class initial_create : Migration + public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.EnsureSchema( + name: "domain"); + migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:postgis", ",,"); migrationBuilder.CreateTable( name: "carriages", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -36,6 +40,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "companies", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -53,6 +58,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "countries", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -67,6 +73,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "routes", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -80,6 +87,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "ticket_documents", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -96,10 +104,12 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "users", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + identity_id = table.Column(type: "int", nullable: false), is_deleted = table.Column(type: "boolean", nullable: false) }, constraints: table => @@ -109,6 +119,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "employees", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -118,6 +129,7 @@ namespace AutobusApi.Persistence.Migrations patronymic = table.Column(type: "varchar(32)", nullable: false), sex = table.Column(type: "varchar(16)", nullable: false), birth_date = table.Column(type: "date", nullable: false), + identity_id = table.Column(type: "int", nullable: false), employer_company_id = table.Column(type: "int", nullable: false), is_deleted = table.Column(type: "boolean", nullable: false) }, @@ -127,6 +139,7 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_employees_companies_employerCompanyId", column: x => x.employer_company_id, + principalSchema: "domain", principalTable: "companies", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -134,6 +147,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "vehicles", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -147,6 +161,7 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_vehicles_companies_companyId", column: x => x.company_id, + principalSchema: "domain", principalTable: "companies", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -154,6 +169,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "regions", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -168,6 +184,7 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_regions_coutries_countryId", column: x => x.country_id, + principalSchema: "domain", principalTable: "countries", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -175,6 +192,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "ticket_groups", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -188,7 +206,7 @@ namespace AutobusApi.Persistence.Migrations passenger_patronymic = table.Column(type: "varchar(32)", nullable: false), passenger_sex = table.Column(type: "varchar(16)", nullable: false), passenger_birth_date = table.Column(type: "date", nullable: false), - purchase_timestamp_utc = table.Column(type: "timestamp", nullable: false), + purchase_timestamp_utc = table.Column(type: "timestamptz", nullable: false), is_returned = table.Column(type: "boolean", nullable: false), user_id = table.Column(type: "int", nullable: true), TicketDocumentId = table.Column(type: "int", nullable: false), @@ -200,12 +218,14 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_ticketGroups_ticketDocuments_ticketDocumentId", column: x => x.TicketDocumentId, + principalSchema: "domain", principalTable: "ticket_documents", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_ticketGroups_users_userId", column: x => x.user_id, + principalSchema: "domain", principalTable: "users", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -213,6 +233,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "employee_documents", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -228,6 +249,7 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_employeeDocuments_employees_employeeId", column: x => x.employee_id, + principalSchema: "domain", principalTable: "employees", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -235,6 +257,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "aircrafts", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false), @@ -250,6 +273,7 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_aircrafts_vehicles_id", column: x => x.id, + principalSchema: "domain", principalTable: "vehicles", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -257,6 +281,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "buses", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false), @@ -275,6 +300,7 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_buses_vehicles_id", column: x => x.id, + principalSchema: "domain", principalTable: "vehicles", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -282,6 +308,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "trains", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false), @@ -293,6 +320,7 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_trains_vehicles_id", column: x => x.id, + principalSchema: "domain", principalTable: "vehicles", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -300,11 +328,12 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "vehicle_enrollments", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - departure_timestamp_utc = table.Column(type: "timestamp", nullable: false), + departure_timestamp_utc = table.Column(type: "timestamptz", nullable: false), vehicle_id = table.Column(type: "int", nullable: false), route_id = table.Column(type: "int", nullable: false), is_deleted = table.Column(type: "boolean", nullable: false) @@ -315,12 +344,14 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_vehicleEnrollments_routes_routeId", column: x => x.route_id, + principalSchema: "domain", principalTable: "routes", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_vehicleEnrollments_vehicles_vehicleId", column: x => x.vehicle_id, + principalSchema: "domain", principalTable: "vehicles", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -328,6 +359,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "cities", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -342,6 +374,7 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_cities_regions_regionId", column: x => x.region_id, + principalSchema: "domain", principalTable: "regions", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -349,6 +382,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "train_carriages", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -363,12 +397,14 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_trainCarriages_trains_carriageId", column: x => x.train_id, + principalSchema: "domain", principalTable: "carriages", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_trainCarriages_trains_trainId", column: x => x.train_id, + principalSchema: "domain", principalTable: "trains", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -376,13 +412,14 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "reviews", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), rating = table.Column(type: "numeric(1,0)", nullable: false), comment = table.Column(type: "varchar(128)", nullable: false), - post_timestamp_utc = table.Column(type: "timestamp", nullable: false), + post_timestamp_utc = table.Column(type: "timestamptz", nullable: false), user_id = table.Column(type: "int", nullable: false), vehicle_enrollment_id = table.Column(type: "int", nullable: false), is_deleted = table.Column(type: "boolean", nullable: false) @@ -393,12 +430,14 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_reviews_users_userId", column: x => x.user_id, + principalSchema: "domain", principalTable: "users", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_reviews_vehicleEnrollments_vehicleEnrollmentId", column: x => x.vehicle_enrollment_id, + principalSchema: "domain", principalTable: "vehicle_enrollments", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -406,6 +445,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "tickets", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -420,12 +460,14 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_tickets_ticketGroups_ticketGroupId", column: x => x.ticket_group_id, + principalSchema: "domain", principalTable: "ticket_groups", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_tickets_vehicleEnrollments_vehicleEnrollmentId", column: x => x.vehicle_enrollment_id, + principalSchema: "domain", principalTable: "vehicle_enrollments", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -433,6 +475,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "vehicle_enrollment_employees", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -447,12 +490,14 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_vehicleEnrollmentEmployees_employees_employeeId", column: x => x.employee_id, + principalSchema: "domain", principalTable: "employees", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_vehicleEnrollmentEmployees_vehicleEnrollments_vehicleEnrollmentId", column: x => x.vehicle_enrollment_id, + principalSchema: "domain", principalTable: "vehicle_enrollments", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -460,6 +505,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "addresses", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -476,6 +522,7 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_addresses_city_id", column: x => x.city_id, + principalSchema: "domain", principalTable: "cities", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -483,6 +530,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "route_addresses", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -498,12 +546,14 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_routeAddresses_addresses_addressId", column: x => x.address_id, + principalSchema: "domain", principalTable: "addresses", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_routeAddresses_routes_routeId", column: x => x.route_id, + principalSchema: "domain", principalTable: "routes", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -511,6 +561,7 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateTable( name: "route_address_details", + schema: "domain", columns: table => new { id = table.Column(type: "int", nullable: false) @@ -528,12 +579,14 @@ namespace AutobusApi.Persistence.Migrations table.ForeignKey( name: "fk_routeAddressDetails_routeAddress_routeAddressId", column: x => x.route_address_id, + principalSchema: "domain", principalTable: "route_addresses", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_routeAddressDetails_vehicleEnrollments_vehicleEnrollmentId", column: x => x.vehicle_enrollment_id, + principalSchema: "domain", principalTable: "vehicle_enrollments", principalColumn: "id", onDelete: ReferentialAction.Cascade); @@ -541,107 +594,142 @@ namespace AutobusApi.Persistence.Migrations migrationBuilder.CreateIndex( name: "IX_addresses_city_id", + schema: "domain", table: "addresses", column: "city_id"); migrationBuilder.CreateIndex( name: "IX_cities_region_id", + schema: "domain", table: "cities", column: "region_id"); migrationBuilder.CreateIndex( name: "IX_employee_documents_employee_id", + schema: "domain", table: "employee_documents", column: "employee_id"); migrationBuilder.CreateIndex( name: "IX_employees_employer_company_id", + schema: "domain", table: "employees", column: "employer_company_id"); + migrationBuilder.CreateIndex( + name: "IX_employees_identity_id", + schema: "domain", + table: "employees", + column: "identity_id", + unique: true); + migrationBuilder.CreateIndex( name: "IX_regions_country_id", + schema: "domain", table: "regions", column: "country_id"); migrationBuilder.CreateIndex( name: "IX_reviews_user_id", + schema: "domain", table: "reviews", column: "user_id"); migrationBuilder.CreateIndex( name: "IX_reviews_vehicle_enrollment_id", + schema: "domain", table: "reviews", column: "vehicle_enrollment_id"); migrationBuilder.CreateIndex( name: "IX_route_address_details_route_address_id", + schema: "domain", table: "route_address_details", column: "route_address_id"); migrationBuilder.CreateIndex( name: "IX_route_address_details_vehicle_enrollment_id", + schema: "domain", table: "route_address_details", column: "vehicle_enrollment_id"); migrationBuilder.CreateIndex( name: "IX_route_addresses_address_id", + schema: "domain", table: "route_addresses", column: "address_id"); migrationBuilder.CreateIndex( name: "IX_route_addresses_route_id", + schema: "domain", table: "route_addresses", column: "route_id"); migrationBuilder.CreateIndex( name: "IX_ticket_groups_TicketDocumentId", + schema: "domain", table: "ticket_groups", column: "TicketDocumentId", unique: true); migrationBuilder.CreateIndex( name: "IX_ticket_groups_user_id", + schema: "domain", table: "ticket_groups", column: "user_id"); migrationBuilder.CreateIndex( name: "IX_tickets_ticket_group_id", + schema: "domain", table: "tickets", column: "ticket_group_id"); migrationBuilder.CreateIndex( name: "IX_tickets_vehicle_enrollment_id", + schema: "domain", table: "tickets", column: "vehicle_enrollment_id"); migrationBuilder.CreateIndex( name: "IX_train_carriages_train_id", + schema: "domain", table: "train_carriages", column: "train_id"); + migrationBuilder.CreateIndex( + name: "IX_users_identity_id", + schema: "domain", + table: "users", + column: "identity_id", + unique: true); + migrationBuilder.CreateIndex( name: "IX_vehicle_enrollment_employees_employee_id", + schema: "domain", table: "vehicle_enrollment_employees", column: "employee_id"); migrationBuilder.CreateIndex( name: "IX_vehicle_enrollment_employees_vehicle_enrollment_id", + schema: "domain", table: "vehicle_enrollment_employees", column: "vehicle_enrollment_id"); migrationBuilder.CreateIndex( name: "IX_vehicle_enrollments_route_id", + schema: "domain", table: "vehicle_enrollments", column: "route_id"); migrationBuilder.CreateIndex( name: "IX_vehicle_enrollments_vehicle_id", + schema: "domain", table: "vehicle_enrollments", column: "vehicle_id"); migrationBuilder.CreateIndex( name: "IX_vehicles_company_id", + schema: "domain", table: "vehicles", column: "company_id"); } @@ -650,73 +738,96 @@ namespace AutobusApi.Persistence.Migrations protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( - name: "aircrafts"); + name: "aircrafts", + schema: "domain"); migrationBuilder.DropTable( - name: "buses"); + name: "buses", + schema: "domain"); migrationBuilder.DropTable( - name: "employee_documents"); + name: "employee_documents", + schema: "domain"); migrationBuilder.DropTable( - name: "reviews"); + name: "reviews", + schema: "domain"); migrationBuilder.DropTable( - name: "route_address_details"); + name: "route_address_details", + schema: "domain"); migrationBuilder.DropTable( - name: "tickets"); + name: "tickets", + schema: "domain"); migrationBuilder.DropTable( - name: "train_carriages"); + name: "train_carriages", + schema: "domain"); migrationBuilder.DropTable( - name: "vehicle_enrollment_employees"); + name: "vehicle_enrollment_employees", + schema: "domain"); migrationBuilder.DropTable( - name: "route_addresses"); + name: "route_addresses", + schema: "domain"); migrationBuilder.DropTable( - name: "ticket_groups"); + name: "ticket_groups", + schema: "domain"); migrationBuilder.DropTable( - name: "carriages"); + name: "carriages", + schema: "domain"); migrationBuilder.DropTable( - name: "trains"); + name: "trains", + schema: "domain"); migrationBuilder.DropTable( - name: "employees"); + name: "employees", + schema: "domain"); migrationBuilder.DropTable( - name: "vehicle_enrollments"); + name: "vehicle_enrollments", + schema: "domain"); migrationBuilder.DropTable( - name: "addresses"); + name: "addresses", + schema: "domain"); migrationBuilder.DropTable( - name: "ticket_documents"); + name: "ticket_documents", + schema: "domain"); migrationBuilder.DropTable( - name: "users"); + name: "users", + schema: "domain"); migrationBuilder.DropTable( - name: "routes"); + name: "routes", + schema: "domain"); migrationBuilder.DropTable( - name: "vehicles"); + name: "vehicles", + schema: "domain"); migrationBuilder.DropTable( - name: "cities"); + name: "cities", + schema: "domain"); migrationBuilder.DropTable( - name: "companies"); + name: "companies", + schema: "domain"); migrationBuilder.DropTable( - name: "regions"); + name: "regions", + schema: "domain"); migrationBuilder.DropTable( - name: "countries"); + name: "countries", + schema: "domain"); } } } diff --git a/AutobusApi.Persistence/Migrations/PostgresContextModelSnapshot.cs b/AutobusApi.Infrastructure/Data/Migrations/ApplicationDbContextModelSnapshot.cs similarity index 95% rename from AutobusApi.Persistence/Migrations/PostgresContextModelSnapshot.cs rename to AutobusApi.Infrastructure/Data/Migrations/ApplicationDbContextModelSnapshot.cs index 556c95f..9f888fa 100644 --- a/AutobusApi.Persistence/Migrations/PostgresContextModelSnapshot.cs +++ b/AutobusApi.Infrastructure/Data/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1,6 +1,6 @@ // using System; -using AutoubsApi.Persistence.Contexts; +using AutoubsApi.Infrastructure.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -9,15 +9,16 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable -namespace AutobusApi.Persistence.Migrations +namespace AutobusApi.Infrastructure.Data.Migrations { - [DbContext(typeof(PostgresContext))] - partial class PostgresContextModelSnapshot : ModelSnapshot + [DbContext(typeof(ApplicationDbContext))] + partial class ApplicationDbContextModelSnapshot : ModelSnapshot { protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder + .HasDefaultSchema("domain") .HasAnnotation("ProductVersion", "7.0.13") .HasAnnotation("Relational:MaxIdentifierLength", 63); @@ -60,7 +61,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("CityId"); - b.ToTable("addresses", (string)null); + b.ToTable("addresses", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Carriage", b => @@ -99,7 +100,7 @@ namespace AutobusApi.Persistence.Migrations b.HasKey("Id"); - b.ToTable("carriages", (string)null); + b.ToTable("carriages", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.City", b => @@ -128,7 +129,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("RegionId"); - b.ToTable("cities", (string)null); + b.ToTable("cities", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Company", b => @@ -166,7 +167,7 @@ namespace AutobusApi.Persistence.Migrations b.HasKey("Id"); - b.ToTable("companies", (string)null); + b.ToTable("companies", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Country", b => @@ -189,7 +190,7 @@ namespace AutobusApi.Persistence.Migrations b.HasKey("Id"); - b.ToTable("countries", (string)null); + b.ToTable("countries", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Employee", b => @@ -214,6 +215,10 @@ namespace AutobusApi.Persistence.Migrations .HasColumnType("varchar(32)") .HasColumnName("first_name"); + b.Property("IdentityId") + .HasColumnType("int") + .HasColumnName("identity_id"); + b.Property("IsDeleted") .HasColumnType("boolean") .HasColumnName("is_deleted"); @@ -237,7 +242,10 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("EmployerCompanyId"); - b.ToTable("employees", (string)null); + b.HasIndex("IdentityId") + .IsUnique(); + + b.ToTable("employees", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.EmployeeDocument", b => @@ -271,7 +279,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("EmployeeId"); - b.ToTable("employee_documents", (string)null); + b.ToTable("employee_documents", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Region", b => @@ -300,7 +308,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("CountryId"); - b.ToTable("regions", (string)null); + b.ToTable("regions", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Review", b => @@ -322,7 +330,7 @@ namespace AutobusApi.Persistence.Migrations .HasColumnName("is_deleted"); b.Property("PostDateTimeUtc") - .HasColumnType("timestamp") + .HasColumnType("timestamptz") .HasColumnName("post_timestamp_utc"); b.Property("Rating") @@ -343,7 +351,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("VehicleEnrollmentId"); - b.ToTable("reviews", (string)null); + b.ToTable("reviews", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Route", b => @@ -361,7 +369,7 @@ namespace AutobusApi.Persistence.Migrations b.HasKey("Id"); - b.ToTable("routes", (string)null); + b.ToTable("routes", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.RouteAddress", b => @@ -395,7 +403,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("RouteId"); - b.ToTable("route_addresses", (string)null); + b.ToTable("route_addresses", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.RouteAddressDetails", b => @@ -437,7 +445,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("VehicleEnrollmentId"); - b.ToTable("route_address_details", (string)null); + b.ToTable("route_address_details", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Ticket", b => @@ -467,7 +475,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("VehicleEnrollmentId"); - b.ToTable("tickets", (string)null); + b.ToTable("tickets", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.TicketDocument", b => @@ -499,7 +507,7 @@ namespace AutobusApi.Persistence.Migrations b.HasKey("Id"); - b.ToTable("ticket_documents", (string)null); + b.ToTable("ticket_documents", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.TicketGroup", b => @@ -564,7 +572,7 @@ namespace AutobusApi.Persistence.Migrations .HasColumnName("passenger_sex"); b.Property("PurchaseDateTimeUtc") - .HasColumnType("timestamp") + .HasColumnType("timestamptz") .HasColumnName("purchase_timestamp_utc"); b.Property("TicketDocumentId") @@ -581,7 +589,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("UserId"); - b.ToTable("ticket_groups", (string)null); + b.ToTable("ticket_groups", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.TrainCarriage", b => @@ -609,7 +617,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("TrainId"); - b.ToTable("train_carriages", (string)null); + b.ToTable("train_carriages", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.User", b => @@ -621,13 +629,20 @@ namespace AutobusApi.Persistence.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("IdentityId") + .HasColumnType("int") + .HasColumnName("identity_id"); + b.Property("IsDeleted") .HasColumnType("boolean") .HasColumnName("is_deleted"); b.HasKey("Id"); - b.ToTable("users", (string)null); + b.HasIndex("IdentityId") + .IsUnique(); + + b.ToTable("users", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Vehicle", b => @@ -651,7 +666,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("CompanyId"); - b.ToTable("vehicles", (string)null); + b.ToTable("vehicles", "domain"); b.UseTptMappingStrategy(); }); @@ -666,7 +681,7 @@ namespace AutobusApi.Persistence.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("DepartureDateTimeUtc") - .HasColumnType("timestamp") + .HasColumnType("timestamptz") .HasColumnName("departure_timestamp_utc"); b.Property("IsDeleted") @@ -687,7 +702,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("VehicleId"); - b.ToTable("vehicle_enrollments", (string)null); + b.ToTable("vehicle_enrollments", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.VehicleEnrollmentEmployee", b => @@ -717,7 +732,7 @@ namespace AutobusApi.Persistence.Migrations b.HasIndex("VehicleEnrollmentId"); - b.ToTable("vehicle_enrollment_employees", (string)null); + b.ToTable("vehicle_enrollment_employees", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Aircraft", b => @@ -746,7 +761,7 @@ namespace AutobusApi.Persistence.Migrations .HasColumnType("varchar(8)") .HasColumnName("number"); - b.ToTable("aircrafts", (string)null); + b.ToTable("aircrafts", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Bus", b => @@ -787,7 +802,7 @@ namespace AutobusApi.Persistence.Migrations .HasColumnType("varchar(8)") .HasColumnName("number"); - b.ToTable("buses", (string)null); + b.ToTable("buses", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Train", b => @@ -799,7 +814,7 @@ namespace AutobusApi.Persistence.Migrations .HasColumnType("varchar(8)") .HasColumnName("number"); - b.ToTable("trains", (string)null); + b.ToTable("trains", "domain"); }); modelBuilder.Entity("AutobusApi.Domain.Entities.Address", b => diff --git a/AutobusApi.Persistence/AutobusApi.Persistence.csproj b/AutobusApi.Persistence/AutobusApi.Persistence.csproj deleted file mode 100644 index f837419..0000000 --- a/AutobusApi.Persistence/AutobusApi.Persistence.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - net7.0 - enable - enable - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - - - - - diff --git a/AutobusApi.Persistence/Contexts/PostgresContext.cs b/AutobusApi.Persistence/Contexts/PostgresContext.cs deleted file mode 100644 index 3241391..0000000 --- a/AutobusApi.Persistence/Contexts/PostgresContext.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Reflection; -using AutobusApi.Domain.Entities; -using Microsoft.EntityFrameworkCore; - -namespace AutoubsApi.Persistence.Contexts; - -public class PostgresContext : DbContext -{ - public PostgresContext(DbContextOptions options) - : base(options) { } - - public DbSet Countries { get; set; } - - public DbSet Regions { get; set; } - - public DbSet Cities { get; set; } - - public DbSet
Addresses { get; set; } - - public DbSet RouteAddresses { get; set; } - - public DbSet Routes { get; set; } - - public DbSet RouteAddressDetails { get; set; } - - public DbSet VehicleEnrollments { get; set; } - - public DbSet Vehicles { get; set; } - - public DbSet Buses { get; set; } - - public DbSet Aircraft { get; set; } - - public DbSet Trains { get; set; } - - public DbSet TrainCarriages { get; set; } - - public DbSet Carriages { get; set; } - - public DbSet Companies { get; set; } - - public DbSet Employees { get; set; } - - public DbSet EmployeeDocuments { get; set; } - - public DbSet vehicleEnrollmentEmployees { get; set; } - - public DbSet Users { get; set; } - - public DbSet TicketGroups { get; set; } - - public DbSet Tickets { get; set; } - - public DbSet TicketDocuments { get; set; } - - public DbSet Reviews { get; set; } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.HasPostgresExtension("postgis"); - - modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); - } -} diff --git a/AutobusApi.sln b/AutobusApi.sln index 7f3cef8..bf0bda7 100644 --- a/AutobusApi.sln +++ b/AutobusApi.sln @@ -13,7 +13,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutobusApi.Infrastructure", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutobusApi.IntegrationTests", "AutobusApi.IntegrationTests\AutobusApi.IntegrationTests.csproj", "{89BC05CE-91D8-440C-89AB-E37D3A6AF49A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutobusApi.Persistence", "AutobusApi.Persistence\AutobusApi.Persistence.csproj", "{3EE87DBF-F48C-4E80-BA41-FDF22C0E9234}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutobusApi.UnitTests", "AutobusApi.UnitTests\AutobusApi.UnitTests.csproj", "{93330D27-069C-4BCD-BE6F-FCF1D2BFE3FE}" EndProject @@ -46,10 +45,6 @@ Global {89BC05CE-91D8-440C-89AB-E37D3A6AF49A}.Debug|Any CPU.Build.0 = Debug|Any CPU {89BC05CE-91D8-440C-89AB-E37D3A6AF49A}.Release|Any CPU.ActiveCfg = Release|Any CPU {89BC05CE-91D8-440C-89AB-E37D3A6AF49A}.Release|Any CPU.Build.0 = Release|Any CPU - {3EE87DBF-F48C-4E80-BA41-FDF22C0E9234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3EE87DBF-F48C-4E80-BA41-FDF22C0E9234}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3EE87DBF-F48C-4E80-BA41-FDF22C0E9234}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3EE87DBF-F48C-4E80-BA41-FDF22C0E9234}.Release|Any CPU.Build.0 = Release|Any CPU {93330D27-069C-4BCD-BE6F-FCF1D2BFE3FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {93330D27-069C-4BCD-BE6F-FCF1D2BFE3FE}.Debug|Any CPU.Build.0 = Debug|Any CPU {93330D27-069C-4BCD-BE6F-FCF1D2BFE3FE}.Release|Any CPU.ActiveCfg = Release|Any CPU