diff --git a/src/ApiGateway/src/Program.cs b/src/ApiGateway/src/Program.cs index 9704e91..8b66c1b 100644 --- a/src/ApiGateway/src/Program.cs +++ b/src/ApiGateway/src/Program.cs @@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Authentication; using Serilog; var builder = WebApplication.CreateBuilder(args); -var configuration = builder.Configuration; var appOptions = builder.Services.GetOptions("AppOptions"); Console.WriteLine(FiggleFonts.Standard.Render(appOptions.Name)); diff --git a/src/BuildingBlocks/Logging/Extensions.cs b/src/BuildingBlocks/Logging/Extensions.cs index 97f85ec..d031f23 100644 --- a/src/BuildingBlocks/Logging/Extensions.cs +++ b/src/BuildingBlocks/Logging/Extensions.cs @@ -1,4 +1,6 @@ using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Enrichers.Span; using Serilog.Events; @@ -10,18 +12,20 @@ public static class Extensions { public static WebApplicationBuilder AddCustomSerilog(this WebApplicationBuilder builder) { - Log.Logger = new LoggerConfiguration() - .WriteTo.Console() - .CreateBootstrapLogger(); - builder.Host.UseSerilog((ctx, lc) => lc - .WriteTo.Console() - .WriteTo.SpectreConsole("{Timestamp:HH:mm:ss} [{Level:u4}] {Message:lj}{NewLine}{Exception}", LogEventLevel.Error) - .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Error) - .Enrich.WithSpan() - .Enrich.FromLogContext() - .ReadFrom.Configuration(ctx.Configuration)); + Log.Logger = new LoggerConfiguration() + .WriteTo.Console() + .CreateBootstrapLogger(); - return builder; + builder.Host.UseSerilog((ctx, lc) => lc + .WriteTo.Console() + .WriteTo.SpectreConsole("{Timestamp:HH:mm:ss} [{Level:u4}] {Message:lj}{NewLine}{Exception}", + LogEventLevel.Error) + .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Error) + .Enrich.WithSpan() + .Enrich.FromLogContext() + .ReadFrom.Configuration(ctx.Configuration)); + + return builder; } } diff --git a/src/BuildingBlocks/MassTransit/Extensions.cs b/src/BuildingBlocks/MassTransit/Extensions.cs index e13711e..28c92a5 100644 --- a/src/BuildingBlocks/MassTransit/Extensions.cs +++ b/src/BuildingBlocks/MassTransit/Extensions.cs @@ -3,7 +3,9 @@ using BuildingBlocks.Domain.Event; using BuildingBlocks.Utils; using Humanizer; using MassTransit; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace BuildingBlocks.MassTransit; @@ -15,56 +17,59 @@ public static class Extensions bool.TryParse(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"), out var inContainer) && inContainer; - public static IServiceCollection AddCustomMassTransit(this IServiceCollection services, Assembly assembly) + public static IServiceCollection AddCustomMassTransit(this IServiceCollection services, Assembly assembly, IWebHostEnvironment env) { - services.AddMassTransit(configure => + if (!env.IsEnvironment("test")) { - configure.AddConsumers(assembly); - - configure.UsingRabbitMq((context, configurator) => + services.AddMassTransit(configure => { - var rabbitMqOptions = services.GetOptions("RabbitMq"); - var host = IsRunningInContainer ? "rabbitmq" : rabbitMqOptions.HostName; + configure.AddConsumers(assembly); - configurator.Host(host, h => + configure.UsingRabbitMq((context, configurator) => { - h.Username(rabbitMqOptions.UserName); - h.Password(rabbitMqOptions.Password); - }); + var rabbitMqOptions = services.GetOptions("RabbitMq"); + var host = IsRunningInContainer ? "rabbitmq" : rabbitMqOptions.HostName; - var types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()) - .Where(x => x.IsAssignableTo(typeof(IIntegrationEvent)) - && !x.IsInterface - && !x.IsAbstract - && !x.IsGenericType); + configurator.Host(host, h => + { + h.Username(rabbitMqOptions.UserName); + h.Password(rabbitMqOptions.Password); + }); - foreach (var type in types) - { - var consumers = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()) - .Where(x => x.IsAssignableTo(typeof(IConsumer<>).MakeGenericType(type))).ToList(); + var types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()) + .Where(x => x.IsAssignableTo(typeof(IIntegrationEvent)) + && !x.IsInterface + && !x.IsAbstract + && !x.IsGenericType); - if (consumers.Any()) - configurator.ReceiveEndpoint( - string.IsNullOrEmpty(rabbitMqOptions.ExchangeName) - ? type.Name.Underscore() - : $"{rabbitMqOptions.ExchangeName}_{type.Name.Underscore()}", e => - { - foreach (var consumer in consumers) + foreach (var type in types) + { + var consumers = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()) + .Where(x => x.IsAssignableTo(typeof(IConsumer<>).MakeGenericType(type))).ToList(); + + if (consumers.Any()) + configurator.ReceiveEndpoint( + string.IsNullOrEmpty(rabbitMqOptions.ExchangeName) + ? type.Name.Underscore() + : $"{rabbitMqOptions.ExchangeName}_{type.Name.Underscore()}", e => { - configurator.ConfigureEndpoints(context, x => x.Exclude(consumer)); - var methodInfo = typeof(DependencyInjectionReceiveEndpointExtensions) - .GetMethods() - .Where(x => x.GetParameters() - .Any(p => p.ParameterType == typeof(IServiceProvider))) - .FirstOrDefault(x => x.Name == "Consumer" && x.IsGenericMethod); + foreach (var consumer in consumers) + { + configurator.ConfigureEndpoints(context, x => x.Exclude(consumer)); + var methodInfo = typeof(DependencyInjectionReceiveEndpointExtensions) + .GetMethods() + .Where(x => x.GetParameters() + .Any(p => p.ParameterType == typeof(IServiceProvider))) + .FirstOrDefault(x => x.Name == "Consumer" && x.IsGenericMethod); - var generic = methodInfo?.MakeGenericMethod(consumer); - generic?.Invoke(e, new object[] {e, context, null}); - } - }); - } + var generic = methodInfo?.MakeGenericMethod(consumer); + generic?.Invoke(e, new object[] {e, context, null}); + } + }); + } + }); }); - }); + } return services; } diff --git a/src/Services/Booking/src/Booking.Api/Program.cs b/src/Services/Booking/src/Booking.Api/Program.cs index 340f300..31822ff 100644 --- a/src/Services/Booking/src/Booking.Api/Program.cs +++ b/src/Services/Booking/src/Booking.Api/Program.cs @@ -23,6 +23,7 @@ using Serilog; var builder = WebApplication.CreateBuilder(args); var configuration = builder.Configuration; +var env = builder.Environment; var appOptions = builder.Services.GetOptions("AppOptions"); builder.Services.Configure(options => configuration.GetSection("Grpc").Bind(options)); @@ -46,7 +47,7 @@ builder.Services.AddHttpContextAccessor(); builder.Services.AddTransient(); builder.Services.AddTransient(); -builder.Services.AddCustomMassTransit(typeof(BookingRoot).Assembly); +builder.Services.AddCustomMassTransit(typeof(BookingRoot).Assembly, env); builder.Services.AddCustomOpenTelemetry(); builder.Services.AddTransient(); SnowFlakIdGenerator.Configure(3); diff --git a/src/Services/Booking/src/Booking.Api/appsettings.docker.json b/src/Services/Booking/src/Booking.Api/appsettings.docker.json index c51b078..96ed73d 100644 --- a/src/Services/Booking/src/Booking.Api/appsettings.docker.json +++ b/src/Services/Booking/src/Booking.Api/appsettings.docker.json @@ -7,7 +7,7 @@ } }, "ConnectionStrings": { - "BookingConnection": "Server=db;Database=BookingDB;User ID=sa;Password=@Aa123456" + "DefaultConnection": "Server=db;Database=BookingDB;User ID=sa;Password=@Aa123456" }, "RabbitMq": { "HostName": "rabbitmq", diff --git a/src/Services/Flight/src/Flight.Api/Program.cs b/src/Services/Flight/src/Flight.Api/Program.cs index cd4d5e5..788e28f 100644 --- a/src/Services/Flight/src/Flight.Api/Program.cs +++ b/src/Services/Flight/src/Flight.Api/Program.cs @@ -8,6 +8,7 @@ using BuildingBlocks.Jwt; using BuildingBlocks.Logging; using BuildingBlocks.Mapster; using BuildingBlocks.MassTransit; +using BuildingBlocks.Mongo; using BuildingBlocks.OpenTelemetry; using BuildingBlocks.Swagger; using BuildingBlocks.Utils; @@ -23,84 +24,77 @@ using Microsoft.AspNetCore.Mvc.ApiExplorer; using Prometheus; using Serilog; -var builder = WebApplication.CreateBuilder(args); -RegisterServices(builder); +var builder = WebApplication.CreateBuilder(args); +var configuration = builder.Configuration; +var env = builder.Environment; + +var appOptions = builder.Services.GetOptions("AppOptions"); +Console.WriteLine(FiggleFonts.Standard.Render(appOptions.Name)); + +builder.Services.AddCustomDbContext(configuration, typeof(FlightRoot).Assembly); +builder.Services.AddMongoDbContext(configuration); + +builder.Services.AddScoped(); +builder.AddCustomSerilog(); +builder.Services.AddJwt(); +builder.Services.AddControllers(); +builder.Services.AddCustomSwagger(builder.Configuration, typeof(FlightRoot).Assembly); +builder.Services.AddCustomVersioning(); +builder.Services.AddCustomMediatR(); +builder.Services.AddValidatorsFromAssembly(typeof(FlightRoot).Assembly); +builder.Services.AddCustomProblemDetails(); +builder.Services.AddCustomMapster(typeof(FlightRoot).Assembly); +builder.Services.AddHttpContextAccessor(); +builder.Services.AddTransient(); +builder.Services.AddCustomMassTransit(typeof(FlightRoot).Assembly, env); +builder.Services.AddCustomOpenTelemetry(); +builder.Services.AddRouting(options => options.LowercaseUrls = true); + +builder.Services.AddGrpc(options => +{ + options.Interceptors.Add(); +}); + +builder.Services.AddMagicOnion(); + +SnowFlakIdGenerator.Configure(1); + +builder.Services.AddCachingRequest(new List +{ + typeof(FlightRoot).Assembly +}); + +builder.Services.AddEasyCaching(options => { options.UseInMemory(configuration, "mem"); }); var app = builder.Build(); -ConfigureApplication(app); +if (app.Environment.IsDevelopment()) +{ + var provider = app.Services.GetService(); + app.UseCustomSwagger(provider); +} +app.UseSerilogRequestLogging(); +app.UseCorrelationId(); +app.UseRouting(); +app.UseHttpMetrics(); +app.UseMigrations(); +app.UseProblemDetails(); +app.UseHttpsRedirection(); +app.UseAuthentication(); +app.UseAuthorization(); + + + +app.UseEndpoints(endpoints => +{ + endpoints.MapControllers(); + endpoints.MapMetrics(); + endpoints.MapMagicOnionService(); +}); + +app.MapGet("/", x => x.Response.WriteAsync(appOptions.Name)); app.Run(); -static void RegisterServices(WebApplicationBuilder builder) -{ - var configuration = builder.Configuration; - var services = builder.Services; - - var appOptions = services.GetOptions("AppOptions"); - Console.WriteLine(FiggleFonts.Standard.Render(appOptions.Name)); - - builder.AddCustomSerilog(); - - services.AddCustomDbContext(configuration, typeof(FlightRoot).Assembly); - services.AddScoped(); - services.AddJwt(); - services.AddControllers(); - services.AddCustomSwagger(builder.Configuration, typeof(FlightRoot).Assembly); - services.AddCustomVersioning(); - services.AddCustomMediatR(); - services.AddValidatorsFromAssembly(typeof(FlightRoot).Assembly); - services.AddCustomProblemDetails(); - services.AddCustomMapster(typeof(FlightRoot).Assembly); - services.AddHttpContextAccessor(); - services.AddTransient(); - services.AddCustomMassTransit(typeof(FlightRoot).Assembly); - services.AddCustomOpenTelemetry(); - services.AddRouting(options => options.LowercaseUrls = true); - - services.AddGrpc(options => - { - options.Interceptors.Add(); - }); - - services.AddMagicOnion(); - - SnowFlakIdGenerator.Configure(1); - - services.AddCachingRequest(new List {typeof(FlightRoot).Assembly}); - - services.AddEasyCaching(options => { options.UseInMemory(configuration, "mem"); }); -} - -static void ConfigureApplication(WebApplication app) -{ - var appOptions = app.GetOptions("AppOptions"); - - if (app.Environment.IsDevelopment()) - { - var provider = app.Services.GetService(); - app.UseCustomSwagger(provider); - } - - app.UseSerilogRequestLogging(); - app.UseCorrelationId(); - app.UseRouting(); - app.UseHttpMetrics(); - app.UseMigrations(); - app.UseProblemDetails(); - app.UseHttpsRedirection(); - app.UseAuthentication(); - app.UseAuthorization(); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - endpoints.MapMetrics(); - endpoints.MapMagicOnionService(); - }); - - app.MapGet("/", x => x.Response.WriteAsync(appOptions.Name)); -} - -public partial class Program { } +public partial class Program {} diff --git a/src/Services/Flight/src/Flight.Api/appsettings.docker.json b/src/Services/Flight/src/Flight.Api/appsettings.docker.json index 947da65..489dba8 100644 --- a/src/Services/Flight/src/Flight.Api/appsettings.docker.json +++ b/src/Services/Flight/src/Flight.Api/appsettings.docker.json @@ -7,7 +7,7 @@ } }, "ConnectionStrings": { - "FlightConnection": "Server=db;Database=FlightDB;User ID=sa;Password=@Aa123456" + "DefaultConnection": "Server=db;Database=FlightDB;User ID=sa;Password=@Aa123456" }, "Jwt": { "Authority": "https://localhost:5005", diff --git a/src/Services/Flight/src/Flight.Api/appsettings.test.json b/src/Services/Flight/src/Flight.Api/appsettings.test.json index 4332d17..059f682 100644 --- a/src/Services/Flight/src/Flight.Api/appsettings.test.json +++ b/src/Services/Flight/src/Flight.Api/appsettings.test.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "FlightConnection": "Server=db;Database=FlightDB;User ID=sa;Password=@Aa123456" + "DefaultConnection": "Server=.\\sqlexpress;Database=FlightDBTest;Trusted_Connection=True;MultipleActiveResultSets=true" }, "RabbitMq": { "HostName": "rabbitmq", diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220303140107_Init.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220303140107_Init.Designer.cs deleted file mode 100644 index 72cd263..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220303140107_Init.Designer.cs +++ /dev/null @@ -1,221 +0,0 @@ -// -using System; -using Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - [Migration("20220303140107_Init")] - partial class Init - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("BuildingBlocks.Outbox.OutboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CorrelationId") - .HasColumnType("nvarchar(max)"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("EventType") - .IsRequired() - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.Property("Type") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("OutboxMessages", (string)null); - }); - - modelBuilder.Entity("Flight.Aircraft.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("ManufacturingYear") - .HasColumnType("int"); - - b.Property("Model") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Aircraft", "dbo"); - }); - - modelBuilder.Entity("Flight.Airport.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Address") - .HasColumnType("nvarchar(max)"); - - b.Property("Code") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Airport", "dbo"); - }); - - modelBuilder.Entity("Flight.Flight.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("AircraftId") - .HasColumnType("bigint"); - - b.Property("ArriveAirportId") - .HasColumnType("bigint"); - - b.Property("ArriveDate") - .HasColumnType("datetime2"); - - b.Property("DepartureAirportId") - .HasColumnType("bigint"); - - b.Property("DepartureDate") - .HasColumnType("datetime2"); - - b.Property("DurationMinutes") - .HasColumnType("decimal(18,2)"); - - b.Property("FlightDate") - .HasColumnType("datetime2"); - - b.Property("FlightNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AircraftId"); - - b.HasIndex("ArriveAirportId"); - - b.ToTable("Flight", "dbo"); - }); - - modelBuilder.Entity("Flight.Flight.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Class") - .HasColumnType("int"); - - b.Property("FlightId") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("SeatNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("FlightId"); - - b.ToTable("Seat", "dbo"); - }); - - modelBuilder.Entity("Flight.Flight.Models.Flight", b => - { - b.HasOne("Flight.Aircraft.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Flight.Airport.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Flight.Models.Seat", b => - { - b.HasOne("Flight.Flight.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220303172333_ModifiedBy-to-entities.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220303172333_ModifiedBy-to-entities.Designer.cs deleted file mode 100644 index acdf976..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220303172333_ModifiedBy-to-entities.Designer.cs +++ /dev/null @@ -1,233 +0,0 @@ -// -using System; -using Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - [Migration("20220303172333_ModifiedBy-to-entities")] - partial class ModifiedBytoentities - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("BuildingBlocks.Outbox.OutboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CorrelationId") - .HasColumnType("nvarchar(max)"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("EventType") - .IsRequired() - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.Property("Type") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("OutboxMessages", (string)null); - }); - - modelBuilder.Entity("Flight.Aircraft.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("ManufacturingYear") - .HasColumnType("int"); - - b.Property("Model") - .HasColumnType("nvarchar(max)"); - - b.Property("ModifiedBy") - .HasColumnType("int"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Aircraft", "dbo"); - }); - - modelBuilder.Entity("Flight.Airport.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Address") - .HasColumnType("nvarchar(max)"); - - b.Property("Code") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("ModifiedBy") - .HasColumnType("int"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Airport", "dbo"); - }); - - modelBuilder.Entity("Flight.Flight.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("AircraftId") - .HasColumnType("bigint"); - - b.Property("ArriveAirportId") - .HasColumnType("bigint"); - - b.Property("ArriveDate") - .HasColumnType("datetime2"); - - b.Property("DepartureAirportId") - .HasColumnType("bigint"); - - b.Property("DepartureDate") - .HasColumnType("datetime2"); - - b.Property("DurationMinutes") - .HasColumnType("decimal(18,2)"); - - b.Property("FlightDate") - .HasColumnType("datetime2"); - - b.Property("FlightNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("ModifiedBy") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AircraftId"); - - b.HasIndex("ArriveAirportId"); - - b.ToTable("Flight", "dbo"); - }); - - modelBuilder.Entity("Flight.Flight.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Class") - .HasColumnType("int"); - - b.Property("FlightId") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("ModifiedBy") - .HasColumnType("int"); - - b.Property("SeatNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("FlightId"); - - b.ToTable("Seat", "dbo"); - }); - - modelBuilder.Entity("Flight.Flight.Models.Flight", b => - { - b.HasOne("Flight.Aircraft.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Flight.Airport.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Flight.Models.Seat", b => - { - b.HasOne("Flight.Flight.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220303172333_ModifiedBy-to-entities.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220303172333_ModifiedBy-to-entities.cs deleted file mode 100644 index 4ae976f..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220303172333_ModifiedBy-to-entities.cs +++ /dev/null @@ -1,63 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Flight.Data.Migrations -{ - public partial class ModifiedBytoentities : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "ModifiedBy", - schema: "dbo", - table: "Seat", - type: "int", - nullable: true); - - migrationBuilder.AddColumn( - name: "ModifiedBy", - schema: "dbo", - table: "Flight", - type: "int", - nullable: true); - - migrationBuilder.AddColumn( - name: "ModifiedBy", - schema: "dbo", - table: "Airport", - type: "int", - nullable: true); - - migrationBuilder.AddColumn( - name: "ModifiedBy", - schema: "dbo", - table: "Aircraft", - type: "int", - nullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "ModifiedBy", - schema: "dbo", - table: "Seat"); - - migrationBuilder.DropColumn( - name: "ModifiedBy", - schema: "dbo", - table: "Flight"); - - migrationBuilder.DropColumn( - name: "ModifiedBy", - schema: "dbo", - table: "Airport"); - - migrationBuilder.DropColumn( - name: "ModifiedBy", - schema: "dbo", - table: "Aircraft"); - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220303182534_Change-corrolationId-type-outbox.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220303182534_Change-corrolationId-type-outbox.Designer.cs deleted file mode 100644 index ad18e82..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220303182534_Change-corrolationId-type-outbox.Designer.cs +++ /dev/null @@ -1,233 +0,0 @@ -// -using System; -using Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - [Migration("20220303182534_Change-corrolationId-type-outbox")] - partial class ChangecorrolationIdtypeoutbox - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("BuildingBlocks.Outbox.OutboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CorrelationId") - .HasColumnType("uniqueidentifier"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("EventType") - .IsRequired() - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.Property("Type") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("OutboxMessages", (string)null); - }); - - modelBuilder.Entity("Flight.Aircraft.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("ManufacturingYear") - .HasColumnType("int"); - - b.Property("Model") - .HasColumnType("nvarchar(max)"); - - b.Property("ModifiedBy") - .HasColumnType("int"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Aircraft", "dbo"); - }); - - modelBuilder.Entity("Flight.Airport.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Address") - .HasColumnType("nvarchar(max)"); - - b.Property("Code") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("ModifiedBy") - .HasColumnType("int"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Airport", "dbo"); - }); - - modelBuilder.Entity("Flight.Flight.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("AircraftId") - .HasColumnType("bigint"); - - b.Property("ArriveAirportId") - .HasColumnType("bigint"); - - b.Property("ArriveDate") - .HasColumnType("datetime2"); - - b.Property("DepartureAirportId") - .HasColumnType("bigint"); - - b.Property("DepartureDate") - .HasColumnType("datetime2"); - - b.Property("DurationMinutes") - .HasColumnType("decimal(18,2)"); - - b.Property("FlightDate") - .HasColumnType("datetime2"); - - b.Property("FlightNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("ModifiedBy") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AircraftId"); - - b.HasIndex("ArriveAirportId"); - - b.ToTable("Flight", "dbo"); - }); - - modelBuilder.Entity("Flight.Flight.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Class") - .HasColumnType("int"); - - b.Property("FlightId") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("ModifiedBy") - .HasColumnType("int"); - - b.Property("SeatNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("FlightId"); - - b.ToTable("Seat", "dbo"); - }); - - modelBuilder.Entity("Flight.Flight.Models.Flight", b => - { - b.HasOne("Flight.Aircraft.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Flight.Airport.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Flight.Models.Seat", b => - { - b.HasOne("Flight.Flight.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220303182534_Change-corrolationId-type-outbox.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220303182534_Change-corrolationId-type-outbox.cs deleted file mode 100644 index 11088dd..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220303182534_Change-corrolationId-type-outbox.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Flight.Data.Migrations -{ - public partial class ChangecorrolationIdtypeoutbox : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "CorrelationId", - table: "OutboxMessages", - type: "uniqueidentifier", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "CorrelationId", - table: "OutboxMessages", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uniqueidentifier", - oldNullable: true); - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220415203349_Add-Versening.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220415203349_Add-Versening.Designer.cs deleted file mode 100644 index 7f788a8..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220415203349_Add-Versening.Designer.cs +++ /dev/null @@ -1,245 +0,0 @@ -// -using System; -using Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - [Migration("20220415203349_Add-Versening")] - partial class AddVersening - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("BuildingBlocks.Outbox.OutboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CorrelationId") - .HasColumnType("uniqueidentifier"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("EventType") - .IsRequired() - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.Property("Type") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("OutboxMessages", (string)null); - }); - - modelBuilder.Entity("Flight.Aircraft.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("ManufacturingYear") - .HasColumnType("int"); - - b.Property("Model") - .HasColumnType("nvarchar(max)"); - - b.Property("ModifiedBy") - .HasColumnType("int"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("Aircraft", "dbo"); - }); - - modelBuilder.Entity("Flight.Airport.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Address") - .HasColumnType("nvarchar(max)"); - - b.Property("Code") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("ModifiedBy") - .HasColumnType("int"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("Airport", "dbo"); - }); - - modelBuilder.Entity("Flight.Flight.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("AircraftId") - .HasColumnType("bigint"); - - b.Property("ArriveAirportId") - .HasColumnType("bigint"); - - b.Property("ArriveDate") - .HasColumnType("datetime2"); - - b.Property("DepartureAirportId") - .HasColumnType("bigint"); - - b.Property("DepartureDate") - .HasColumnType("datetime2"); - - b.Property("DurationMinutes") - .HasColumnType("decimal(18,2)"); - - b.Property("FlightDate") - .HasColumnType("datetime2"); - - b.Property("FlightNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("ModifiedBy") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("AircraftId"); - - b.HasIndex("ArriveAirportId"); - - b.ToTable("Flight", "dbo"); - }); - - modelBuilder.Entity("Flight.Flight.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Class") - .HasColumnType("int"); - - b.Property("FlightId") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("ModifiedBy") - .HasColumnType("int"); - - b.Property("SeatNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("Type") - .HasColumnType("int"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("FlightId"); - - b.ToTable("Seat", "dbo"); - }); - - modelBuilder.Entity("Flight.Flight.Models.Flight", b => - { - b.HasOne("Flight.Aircraft.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Flight.Airport.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Flight.Models.Seat", b => - { - b.HasOne("Flight.Flight.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220415203349_Add-Versening.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220415203349_Add-Versening.cs deleted file mode 100644 index 357bea5..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220415203349_Add-Versening.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Flight.Data.Migrations -{ - public partial class AddVersening : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Version", - schema: "dbo", - table: "Seat", - type: "bigint", - nullable: false, - defaultValue: 0L); - - migrationBuilder.AddColumn( - name: "Version", - schema: "dbo", - table: "Flight", - type: "bigint", - nullable: false, - defaultValue: 0L); - - migrationBuilder.AddColumn( - name: "Version", - schema: "dbo", - table: "Airport", - type: "bigint", - nullable: false, - defaultValue: 0L); - - migrationBuilder.AddColumn( - name: "Version", - schema: "dbo", - table: "Aircraft", - type: "bigint", - nullable: false, - defaultValue: 0L); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Version", - schema: "dbo", - table: "Seat"); - - migrationBuilder.DropColumn( - name: "Version", - schema: "dbo", - table: "Flight"); - - migrationBuilder.DropColumn( - name: "Version", - schema: "dbo", - table: "Airport"); - - migrationBuilder.DropColumn( - name: "Version", - schema: "dbo", - table: "Aircraft"); - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220416172637_Add-Audit.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220416172637_Add-Audit.Designer.cs deleted file mode 100644 index a564940..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220416172637_Add-Audit.Designer.cs +++ /dev/null @@ -1,269 +0,0 @@ -// -using System; -using Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - [Migration("20220416172637_Add-Audit")] - partial class AddAudit - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("BuildingBlocks.Outbox.OutboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CorrelationId") - .HasColumnType("uniqueidentifier"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("EventType") - .IsRequired() - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.Property("Type") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("OutboxMessages", (string)null); - }); - - modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("int"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("int"); - - b.Property("ManufacturingYear") - .HasColumnType("int"); - - b.Property("Model") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("Aircraft", "dbo"); - }); - - modelBuilder.Entity("Flight.Airports.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Address") - .HasColumnType("nvarchar(max)"); - - b.Property("Code") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("int"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("int"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("Airport", "dbo"); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("AircraftId") - .HasColumnType("bigint"); - - b.Property("ArriveAirportId") - .HasColumnType("bigint"); - - b.Property("ArriveDate") - .HasColumnType("datetime2"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("int"); - - b.Property("DepartureAirportId") - .HasColumnType("bigint"); - - b.Property("DepartureDate") - .HasColumnType("datetime2"); - - b.Property("DurationMinutes") - .HasColumnType("decimal(18,2)"); - - b.Property("FlightDate") - .HasColumnType("datetime2"); - - b.Property("FlightNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("AircraftId"); - - b.HasIndex("ArriveAirportId"); - - b.ToTable("Flight", "dbo"); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Class") - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("int"); - - b.Property("FlightId") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("int"); - - b.Property("SeatNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("Type") - .HasColumnType("int"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("FlightId"); - - b.ToTable("Seat", "dbo"); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.HasOne("Flight.Aircrafts.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.HasOne("Flight.Flights.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220416172637_Add-Audit.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220416172637_Add-Audit.cs deleted file mode 100644 index 8afc8bd..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220416172637_Add-Audit.cs +++ /dev/null @@ -1,240 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Flight.Data.Migrations -{ - public partial class AddAudit : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "ModifiedBy", - schema: "dbo", - table: "Seat", - newName: "LastModifiedBy"); - - migrationBuilder.RenameColumn( - name: "ModifiedBy", - schema: "dbo", - table: "Flight", - newName: "LastModifiedBy"); - - migrationBuilder.RenameColumn( - name: "ModifiedBy", - schema: "dbo", - table: "Airport", - newName: "LastModifiedBy"); - - migrationBuilder.RenameColumn( - name: "ModifiedBy", - schema: "dbo", - table: "Aircraft", - newName: "LastModifiedBy"); - - migrationBuilder.AlterColumn( - name: "LastModified", - schema: "dbo", - table: "Seat", - type: "datetime2", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "datetime2"); - - migrationBuilder.AddColumn( - name: "CreatedAt", - schema: "dbo", - table: "Seat", - type: "datetime2", - nullable: true); - - migrationBuilder.AddColumn( - name: "CreatedBy", - schema: "dbo", - table: "Seat", - type: "int", - nullable: true); - - migrationBuilder.AlterColumn( - name: "LastModified", - schema: "dbo", - table: "Flight", - type: "datetime2", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "datetime2"); - - migrationBuilder.AddColumn( - name: "CreatedAt", - schema: "dbo", - table: "Flight", - type: "datetime2", - nullable: true); - - migrationBuilder.AddColumn( - name: "CreatedBy", - schema: "dbo", - table: "Flight", - type: "int", - nullable: true); - - migrationBuilder.AlterColumn( - name: "LastModified", - schema: "dbo", - table: "Airport", - type: "datetime2", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "datetime2"); - - migrationBuilder.AddColumn( - name: "CreatedAt", - schema: "dbo", - table: "Airport", - type: "datetime2", - nullable: true); - - migrationBuilder.AddColumn( - name: "CreatedBy", - schema: "dbo", - table: "Airport", - type: "int", - nullable: true); - - migrationBuilder.AlterColumn( - name: "LastModified", - schema: "dbo", - table: "Aircraft", - type: "datetime2", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "datetime2"); - - migrationBuilder.AddColumn( - name: "CreatedAt", - schema: "dbo", - table: "Aircraft", - type: "datetime2", - nullable: true); - - migrationBuilder.AddColumn( - name: "CreatedBy", - schema: "dbo", - table: "Aircraft", - type: "int", - nullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "CreatedAt", - schema: "dbo", - table: "Seat"); - - migrationBuilder.DropColumn( - name: "CreatedBy", - schema: "dbo", - table: "Seat"); - - migrationBuilder.DropColumn( - name: "CreatedAt", - schema: "dbo", - table: "Flight"); - - migrationBuilder.DropColumn( - name: "CreatedBy", - schema: "dbo", - table: "Flight"); - - migrationBuilder.DropColumn( - name: "CreatedAt", - schema: "dbo", - table: "Airport"); - - migrationBuilder.DropColumn( - name: "CreatedBy", - schema: "dbo", - table: "Airport"); - - migrationBuilder.DropColumn( - name: "CreatedAt", - schema: "dbo", - table: "Aircraft"); - - migrationBuilder.DropColumn( - name: "CreatedBy", - schema: "dbo", - table: "Aircraft"); - - migrationBuilder.RenameColumn( - name: "LastModifiedBy", - schema: "dbo", - table: "Seat", - newName: "ModifiedBy"); - - migrationBuilder.RenameColumn( - name: "LastModifiedBy", - schema: "dbo", - table: "Flight", - newName: "ModifiedBy"); - - migrationBuilder.RenameColumn( - name: "LastModifiedBy", - schema: "dbo", - table: "Airport", - newName: "ModifiedBy"); - - migrationBuilder.RenameColumn( - name: "LastModifiedBy", - schema: "dbo", - table: "Aircraft", - newName: "ModifiedBy"); - - migrationBuilder.AlterColumn( - name: "LastModified", - schema: "dbo", - table: "Seat", - type: "datetime2", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "datetime2", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "LastModified", - schema: "dbo", - table: "Flight", - type: "datetime2", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "datetime2", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "LastModified", - schema: "dbo", - table: "Airport", - type: "datetime2", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "datetime2", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "LastModified", - schema: "dbo", - table: "Aircraft", - type: "datetime2", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "datetime2", - oldNullable: true); - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220418195957_Update-Audit.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220418195957_Update-Audit.cs deleted file mode 100644 index d1350e4..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220418195957_Update-Audit.cs +++ /dev/null @@ -1,175 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Flight.Data.Migrations -{ - public partial class UpdateAudit : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "LastModifiedBy", - schema: "dbo", - table: "Seat", - type: "bigint", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CreatedBy", - schema: "dbo", - table: "Seat", - type: "bigint", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "LastModifiedBy", - schema: "dbo", - table: "Flight", - type: "bigint", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CreatedBy", - schema: "dbo", - table: "Flight", - type: "bigint", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "LastModifiedBy", - schema: "dbo", - table: "Airport", - type: "bigint", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CreatedBy", - schema: "dbo", - table: "Airport", - type: "bigint", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "LastModifiedBy", - schema: "dbo", - table: "Aircraft", - type: "bigint", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CreatedBy", - schema: "dbo", - table: "Aircraft", - type: "bigint", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "LastModifiedBy", - schema: "dbo", - table: "Seat", - type: "int", - nullable: true, - oldClrType: typeof(long), - oldType: "bigint", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CreatedBy", - schema: "dbo", - table: "Seat", - type: "int", - nullable: true, - oldClrType: typeof(long), - oldType: "bigint", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "LastModifiedBy", - schema: "dbo", - table: "Flight", - type: "int", - nullable: true, - oldClrType: typeof(long), - oldType: "bigint", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CreatedBy", - schema: "dbo", - table: "Flight", - type: "int", - nullable: true, - oldClrType: typeof(long), - oldType: "bigint", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "LastModifiedBy", - schema: "dbo", - table: "Airport", - type: "int", - nullable: true, - oldClrType: typeof(long), - oldType: "bigint", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CreatedBy", - schema: "dbo", - table: "Airport", - type: "int", - nullable: true, - oldClrType: typeof(long), - oldType: "bigint", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "LastModifiedBy", - schema: "dbo", - table: "Aircraft", - type: "int", - nullable: true, - oldClrType: typeof(long), - oldType: "bigint", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CreatedBy", - schema: "dbo", - table: "Aircraft", - type: "int", - nullable: true, - oldClrType: typeof(long), - oldType: "bigint", - oldNullable: true); - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220421195137_Add-Internal-Messages.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220421195137_Add-Internal-Messages.Designer.cs deleted file mode 100644 index 55664f0..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220421195137_Add-Internal-Messages.Designer.cs +++ /dev/null @@ -1,301 +0,0 @@ -// -using System; -using Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - [Migration("20220421195137_Add-Internal-Messages")] - partial class AddInternalMessages - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("BuildingBlocks.InternalProcessor.InternalMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CommandType") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CorrelationId") - .HasColumnType("uniqueidentifier"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.HasKey("Id"); - - b.ToTable("InternalMessages", (string)null); - }); - - modelBuilder.Entity("BuildingBlocks.Outbox.OutboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CorrelationId") - .HasColumnType("uniqueidentifier"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("EventType") - .IsRequired() - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.Property("Type") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("OutboxMessages", (string)null); - }); - - modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint"); - - b.Property("ManufacturingYear") - .HasColumnType("int"); - - b.Property("Model") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("Aircraft", "dbo"); - }); - - modelBuilder.Entity("Flight.Airports.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Address") - .HasColumnType("nvarchar(max)"); - - b.Property("Code") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("Airport", "dbo"); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("AircraftId") - .HasColumnType("bigint"); - - b.Property("ArriveAirportId") - .HasColumnType("bigint"); - - b.Property("ArriveDate") - .HasColumnType("datetime2"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("bigint"); - - b.Property("DepartureAirportId") - .HasColumnType("bigint"); - - b.Property("DepartureDate") - .HasColumnType("datetime2"); - - b.Property("DurationMinutes") - .HasColumnType("decimal(18,2)"); - - b.Property("FlightDate") - .HasColumnType("datetime2"); - - b.Property("FlightNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint"); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("AircraftId"); - - b.HasIndex("ArriveAirportId"); - - b.ToTable("Flight", "dbo"); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Class") - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("bigint"); - - b.Property("FlightId") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint"); - - b.Property("SeatNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("Type") - .HasColumnType("int"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("FlightId"); - - b.ToTable("Seat", "dbo"); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.HasOne("Flight.Aircrafts.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.HasOne("Flight.Flights.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220421195137_Add-Internal-Messages.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220421195137_Add-Internal-Messages.cs deleted file mode 100644 index 4040394..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220421195137_Add-Internal-Messages.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Flight.Data.Migrations -{ - public partial class AddInternalMessages : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "InternalMessages", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: false), - OccurredOn = table.Column(type: "datetime2", nullable: false), - CommandType = table.Column(type: "nvarchar(max)", nullable: false), - Data = table.Column(type: "nvarchar(max)", nullable: false), - ProcessedOn = table.Column(type: "datetime2", nullable: true), - CorrelationId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_InternalMessages", x => x.Id); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "InternalMessages"); - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220422121403_Update-EventId.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220422121403_Update-EventId.Designer.cs deleted file mode 100644 index 7de476a..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220422121403_Update-EventId.Designer.cs +++ /dev/null @@ -1,301 +0,0 @@ -// -using System; -using Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - [Migration("20220422121403_Update-EventId")] - partial class UpdateEventId - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("BuildingBlocks.InternalProcessor.InternalMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CommandType") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CorrelationId") - .HasColumnType("uniqueidentifier"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.HasKey("Id"); - - b.ToTable("InternalMessages", (string)null); - }); - - modelBuilder.Entity("BuildingBlocks.Outbox.OutboxMessage", b => - { - b.Property("EventId") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CorrelationId") - .HasColumnType("uniqueidentifier"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("EventType") - .IsRequired() - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.Property("Type") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("EventId"); - - b.ToTable("OutboxMessages", (string)null); - }); - - modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint"); - - b.Property("ManufacturingYear") - .HasColumnType("int"); - - b.Property("Model") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("Aircraft", "dbo"); - }); - - modelBuilder.Entity("Flight.Airports.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Address") - .HasColumnType("nvarchar(max)"); - - b.Property("Code") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("Airport", "dbo"); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("AircraftId") - .HasColumnType("bigint"); - - b.Property("ArriveAirportId") - .HasColumnType("bigint"); - - b.Property("ArriveDate") - .HasColumnType("datetime2"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("bigint"); - - b.Property("DepartureAirportId") - .HasColumnType("bigint"); - - b.Property("DepartureDate") - .HasColumnType("datetime2"); - - b.Property("DurationMinutes") - .HasColumnType("decimal(18,2)"); - - b.Property("FlightDate") - .HasColumnType("datetime2"); - - b.Property("FlightNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint"); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("AircraftId"); - - b.HasIndex("ArriveAirportId"); - - b.ToTable("Flight", "dbo"); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Class") - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("bigint"); - - b.Property("FlightId") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint"); - - b.Property("SeatNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("Type") - .HasColumnType("int"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("FlightId"); - - b.ToTable("Seat", "dbo"); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.HasOne("Flight.Aircrafts.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.HasOne("Flight.Flights.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220422121403_Update-EventId.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220422121403_Update-EventId.cs deleted file mode 100644 index e05e51a..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220422121403_Update-EventId.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Flight.Data.Migrations -{ - public partial class UpdateEventId : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "Id", - table: "OutboxMessages", - newName: "EventId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "EventId", - table: "OutboxMessages", - newName: "Id"); - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220422122146_Update-Internal.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220422122146_Update-Internal.Designer.cs deleted file mode 100644 index aa2267b..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220422122146_Update-Internal.Designer.cs +++ /dev/null @@ -1,301 +0,0 @@ -// -using System; -using Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - [Migration("20220422122146_Update-Internal")] - partial class UpdateInternal - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("BuildingBlocks.InternalProcessor.InternalMessage", b => - { - b.Property("EventId") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CommandType") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CorrelationId") - .HasColumnType("uniqueidentifier"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.HasKey("EventId"); - - b.ToTable("InternalMessages", (string)null); - }); - - modelBuilder.Entity("BuildingBlocks.Outbox.OutboxMessage", b => - { - b.Property("EventId") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CorrelationId") - .HasColumnType("uniqueidentifier"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("EventType") - .IsRequired() - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.Property("Type") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("EventId"); - - b.ToTable("OutboxMessages", (string)null); - }); - - modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint"); - - b.Property("ManufacturingYear") - .HasColumnType("int"); - - b.Property("Model") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("Aircraft", "dbo"); - }); - - modelBuilder.Entity("Flight.Airports.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Address") - .HasColumnType("nvarchar(max)"); - - b.Property("Code") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("Airport", "dbo"); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("AircraftId") - .HasColumnType("bigint"); - - b.Property("ArriveAirportId") - .HasColumnType("bigint"); - - b.Property("ArriveDate") - .HasColumnType("datetime2"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("bigint"); - - b.Property("DepartureAirportId") - .HasColumnType("bigint"); - - b.Property("DepartureDate") - .HasColumnType("datetime2"); - - b.Property("DurationMinutes") - .HasColumnType("decimal(18,2)"); - - b.Property("FlightDate") - .HasColumnType("datetime2"); - - b.Property("FlightNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint"); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("AircraftId"); - - b.HasIndex("ArriveAirportId"); - - b.ToTable("Flight", "dbo"); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("Class") - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("bigint"); - - b.Property("FlightId") - .HasColumnType("bigint"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint"); - - b.Property("SeatNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("Type") - .HasColumnType("int"); - - b.Property("Version") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("FlightId"); - - b.ToTable("Seat", "dbo"); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.HasOne("Flight.Aircrafts.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.HasOne("Flight.Flights.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220422122146_Update-Internal.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220422122146_Update-Internal.cs deleted file mode 100644 index 7a4648d..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220422122146_Update-Internal.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Flight.Data.Migrations -{ - public partial class UpdateInternal : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "Id", - table: "InternalMessages", - newName: "EventId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "EventId", - table: "InternalMessages", - newName: "Id"); - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220418195957_Update-Audit.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220509213249_Init.Designer.cs similarity index 84% rename from src/Services/Flight/src/Flight/Data/Migrations/20220418195957_Update-Audit.Designer.cs rename to src/Services/Flight/src/Flight/Data/Migrations/20220509213249_Init.Designer.cs index 149d824..cd10e02 100644 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220418195957_Update-Audit.Designer.cs +++ b/src/Services/Flight/src/Flight/Data/Migrations/20220509213249_Init.Designer.cs @@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Flight.Data.Migrations { [DbContext(typeof(FlightDbContext))] - [Migration("20220418195957_Update-Audit")] - partial class UpdateAudit + [Migration("20220509213249_Init")] + partial class Init { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -24,44 +24,6 @@ namespace Flight.Data.Migrations SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - modelBuilder.Entity("BuildingBlocks.Outbox.OutboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CorrelationId") - .HasColumnType("uniqueidentifier"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("EventType") - .IsRequired() - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.Property("Type") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("OutboxMessages", (string)null); - }); - modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b => { b.Property("Id") diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20220303140107_Init.cs b/src/Services/Flight/src/Flight/Data/Migrations/20220509213249_Init.cs similarity index 81% rename from src/Services/Flight/src/Flight/Data/Migrations/20220303140107_Init.cs rename to src/Services/Flight/src/Flight/Data/Migrations/20220509213249_Init.cs index 155eb66..1cee26d 100644 --- a/src/Services/Flight/src/Flight/Data/Migrations/20220303140107_Init.cs +++ b/src/Services/Flight/src/Flight/Data/Migrations/20220509213249_Init.cs @@ -21,7 +21,11 @@ namespace Flight.Data.Migrations Name = table.Column(type: "nvarchar(max)", nullable: true), Model = table.Column(type: "nvarchar(max)", nullable: true), ManufacturingYear = table.Column(type: "int", nullable: false), - LastModified = table.Column(type: "datetime2", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: true), + CreatedBy = table.Column(type: "bigint", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "bigint", nullable: true), + Version = table.Column(type: "bigint", nullable: false), IsDeleted = table.Column(type: "bit", nullable: false) }, constraints: table => @@ -38,7 +42,11 @@ namespace Flight.Data.Migrations Name = table.Column(type: "nvarchar(max)", nullable: true), Address = table.Column(type: "nvarchar(max)", nullable: true), Code = table.Column(type: "nvarchar(max)", nullable: true), - LastModified = table.Column(type: "datetime2", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: true), + CreatedBy = table.Column(type: "bigint", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "bigint", nullable: true), + Version = table.Column(type: "bigint", nullable: false), IsDeleted = table.Column(type: "bit", nullable: false) }, constraints: table => @@ -46,24 +54,6 @@ namespace Flight.Data.Migrations table.PrimaryKey("PK_Airport", x => x.Id); }); - migrationBuilder.CreateTable( - name: "OutboxMessages", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: false), - OccurredOn = table.Column(type: "datetime2", nullable: false), - Type = table.Column(type: "nvarchar(max)", nullable: false), - Data = table.Column(type: "nvarchar(max)", nullable: false), - ProcessedOn = table.Column(type: "datetime2", nullable: true), - EventType = table.Column(type: "varchar(50)", unicode: false, maxLength: 50, nullable: false), - CorrelationId = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_OutboxMessages", x => x.Id); - }); - migrationBuilder.CreateTable( name: "Flight", schema: "dbo", @@ -80,7 +70,11 @@ namespace Flight.Data.Migrations FlightDate = table.Column(type: "datetime2", nullable: false), Status = table.Column(type: "int", nullable: false), Price = table.Column(type: "decimal(18,2)", nullable: false), - LastModified = table.Column(type: "datetime2", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: true), + CreatedBy = table.Column(type: "bigint", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "bigint", nullable: true), + Version = table.Column(type: "bigint", nullable: false), IsDeleted = table.Column(type: "bit", nullable: false) }, constraints: table => @@ -112,7 +106,11 @@ namespace Flight.Data.Migrations Type = table.Column(type: "int", nullable: false), Class = table.Column(type: "int", nullable: false), FlightId = table.Column(type: "bigint", nullable: false), - LastModified = table.Column(type: "datetime2", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: true), + CreatedBy = table.Column(type: "bigint", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "bigint", nullable: true), + Version = table.Column(type: "bigint", nullable: false), IsDeleted = table.Column(type: "bit", nullable: false) }, constraints: table => @@ -148,9 +146,6 @@ namespace Flight.Data.Migrations protected override void Down(MigrationBuilder migrationBuilder) { - migrationBuilder.DropTable( - name: "OutboxMessages"); - migrationBuilder.DropTable( name: "Seat", schema: "dbo"); diff --git a/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs b/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs index 37f579c..de7d19c 100644 --- a/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs +++ b/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs @@ -22,76 +22,6 @@ namespace Flight.Data.Migrations SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - modelBuilder.Entity("BuildingBlocks.InternalProcessor.InternalMessage", b => - { - b.Property("EventId") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CommandType") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CorrelationId") - .HasColumnType("uniqueidentifier"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.HasKey("EventId"); - - b.ToTable("InternalMessages", (string)null); - }); - - modelBuilder.Entity("BuildingBlocks.Outbox.OutboxMessage", b => - { - b.Property("EventId") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CorrelationId") - .HasColumnType("uniqueidentifier"); - - b.Property("Data") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("EventType") - .IsRequired() - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OccurredOn") - .HasColumnType("datetime2"); - - b.Property("ProcessedOn") - .HasColumnType("datetime2"); - - b.Property("Type") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("EventId"); - - b.ToTable("OutboxMessages", (string)null); - }); - modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b => { b.Property("Id") diff --git a/src/Services/Flight/src/Flight/Flight.csproj b/src/Services/Flight/src/Flight/Flight.csproj index ce19486..b252a70 100644 --- a/src/Services/Flight/src/Flight/Flight.csproj +++ b/src/Services/Flight/src/Flight/Flight.csproj @@ -12,16 +12,16 @@ - - - - - - + + + + + + - + diff --git a/src/Services/Flight/tests/DeleteTests.cs b/src/Services/Flight/tests/DeleteTests.cs index 1dd0942..749f9ca 100644 --- a/src/Services/Flight/tests/DeleteTests.cs +++ b/src/Services/Flight/tests/DeleteTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Threading.Tasks; +using System.Threading.Tasks; using Xunit; namespace Integration.Test; @@ -12,9 +11,9 @@ public class DeleteTests public DeleteTests(TestFixture fixture) => _fixture = fixture; [Fact] - public async Task Should_delete_flight() + public Task Should_delete_flight() { - var b = 2; + return Task.CompletedTask; } } diff --git a/src/Services/Flight/tests/DockerTestUtilities/DockerDatabaseUtilities.cs b/src/Services/Flight/tests/DockerTestUtilities/DockerDatabaseUtilities.cs deleted file mode 100644 index 479ad43..0000000 --- a/src/Services/Flight/tests/DockerTestUtilities/DockerDatabaseUtilities.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using Ductus.FluentDocker.Builders; -using Ductus.FluentDocker.Services; -using Ductus.FluentDocker.Services.Extensions; - -namespace Integration.Test.DockerTestUtilities; - -public static class DockerDatabaseUtilities -{ - private const string ACCEPT_EULA = "Y"; - private const string SA_PASSWORD = "@Aa123456"; - private const string DB_CONTAINER_NAME = "sqldb"; - private static readonly ImageTag ImageTagForOs = new("mcr.microsoft.com/mssql/server", "2017-latest"); - - public static async Task EnsureDockerStartedAndGetPortPortAsync() - { - await DockerUtilities.CleanupRunningContainers(DB_CONTAINER_NAME); - await DockerUtilities.CleanupRunningVolumes(DB_CONTAINER_NAME); - - var hosts = new Hosts().Discover(); - var docker = hosts.FirstOrDefault(x => x.IsNative) ?? hosts.FirstOrDefault(x => x.Name == "default"); - - // create container, if one doesn't already exist - var existingContainer = docker?.GetContainers().FirstOrDefault(c => c.Name == DB_CONTAINER_NAME); - - if (existingContainer == null) - { - var container = new Builder().UseContainer() - .WithName(DB_CONTAINER_NAME) - .UseImage($"{ImageTagForOs.Image}:{ImageTagForOs.Tag}") - .ExposePort(1433, 1433) - .WithEnvironment( - $"SA_PASSWORD={SA_PASSWORD}", - $"ACCEPT_EULA={ACCEPT_EULA}") - .WaitForPort("1433/tcp", 30000 /*30s*/) - .Build(); - - container.Start(); - - await DockerUtilities.WaitUntilDatabaseAvailableAsync(GetSqlConnectionString()); - } - - return existingContainer.ToHostExposedEndpoint("1433/tcp").Port; - } - - // SQL Server 2019 does not work on macOS + M1 chip. So we use SQL Edge as a workaround until SQL Server 2022 is GA. - // See https://github.com/pdevito3/craftsman/issues/53 for details. - private static ImageTag GetImageTagForOs() - { - var sqlServerImageTag = new ImageTag("mcr.microsoft.com/mssql/server", "2019-latest"); - var sqlEdgeImageTag = new ImageTag("mcr.microsoft.com/azure-sql-edge", "latest"); - return IsRunningOnMacOsArm64() ? sqlEdgeImageTag : sqlServerImageTag; - } - - private static bool IsRunningOnMacOsArm64() - { - var isMacOs = RuntimeInformation.IsOSPlatform(OSPlatform.OSX); - var cpuArch = RuntimeInformation.ProcessArchitecture; - return isMacOs && cpuArch == Architecture.Arm64; - } - - public static string GetSqlConnectionString() - { - return DockerUtilities.GetSqlConnectionString(); - } - - private record ImageTag(string Image, string Tag); -} diff --git a/src/Services/Flight/tests/DockerTestUtilities/DockerUtilities.cs b/src/Services/Flight/tests/DockerTestUtilities/DockerUtilities.cs deleted file mode 100644 index fa42694..0000000 --- a/src/Services/Flight/tests/DockerTestUtilities/DockerUtilities.cs +++ /dev/null @@ -1,135 +0,0 @@ -// based on https://blog.dangl.me/archive/running-sql-server-integration-tests-in-net-core-projects-via-docker/ - -using System; -using System.Linq; -using System.Net; -using System.Net.Sockets; -using System.Threading.Tasks; -using Docker.DotNet; -using Docker.DotNet.Models; -using Microsoft.Data.SqlClient; - -namespace Integration.Test.DockerTestUtilities; - -public static class DockerUtilities -{ - private static bool IsRunningOnWindows() - { - return Environment.OSVersion.Platform == PlatformID.Win32NT; - } - - public static DockerClient GetDockerClient() - { - var dockerUri = IsRunningOnWindows() - ? "npipe://./pipe/docker_engine" - : "unix:///var/run/docker.sock"; - return new DockerClientConfiguration(new Uri(dockerUri)) - .CreateClient(); - } - - public static async Task CleanupRunningContainers(string containerName, int hoursTillExpiration = -24) - { - var dockerClient = GetDockerClient(); - - var runningContainers = await dockerClient.Containers - .ListContainersAsync(new ContainersListParameters()); - - foreach (var runningContainer in - runningContainers.Where(cont => cont.Names.Any(n => n.Contains(containerName)))) - { - // Stopping all test containers that are older than 24 hours - var expiration = hoursTillExpiration > 0 - ? hoursTillExpiration * -1 - : hoursTillExpiration; - if (runningContainer.Created < DateTime.UtcNow.AddHours(expiration)) - try - { - await EnsureDockerContainersStoppedAndRemovedAsync(runningContainer.ID); - } - catch - { - // Ignoring failures to stop running containers - } - } - } - - public static async Task CleanupRunningVolumes(string volumeName, int hoursTillExpiration = -24) - { - var dockerClient = GetDockerClient(); - - var runningVolumes = await dockerClient.Volumes.ListAsync(); - - foreach (var runningVolume in runningVolumes.Volumes.Where(v => v.Name == volumeName)) - { - // Stopping all test volumes that are older than 24 hours - var expiration = hoursTillExpiration > 0 - ? hoursTillExpiration * -1 - : hoursTillExpiration; - if (DateTime.Parse(runningVolume.CreatedAt) < DateTime.UtcNow.AddHours(expiration)) - try - { - await EnsureDockerVolumesRemovedAsync(runningVolume.Name); - } - catch - { - // Ignoring failures to stop running containers - } - } - } - - public static async Task EnsureDockerContainersStoppedAndRemovedAsync(string dockerContainerId) - { - var dockerClient = GetDockerClient(); - await dockerClient.Containers - .StopContainerAsync(dockerContainerId, new ContainerStopParameters()); - await dockerClient.Containers - .RemoveContainerAsync(dockerContainerId, new ContainerRemoveParameters()); - } - - public static async Task EnsureDockerVolumesRemovedAsync(string volumeName) - { - var dockerClient = GetDockerClient(); - await dockerClient.Volumes.RemoveAsync(volumeName); - } - - public static async Task WaitUntilDatabaseAvailableAsync(string connectionString) - { - var start = DateTime.UtcNow; - const int maxWaitTimeSeconds = 60; - var connectionEstablished = false; - while (!connectionEstablished && start.AddSeconds(maxWaitTimeSeconds) > DateTime.UtcNow) - try - { - using var sqlConnection = new SqlConnection(connectionString); - await sqlConnection.OpenAsync(); - connectionEstablished = true; - } - catch - { - // If opening the SQL connection fails, SQL Server is not ready yet - await Task.Delay(500); - } - - if (!connectionEstablished) - throw new Exception( - $"Connection to the SQL docker database could not be established within {maxWaitTimeSeconds} seconds."); - } - - public static int GetFreePort() - { - // From https://stackoverflow.com/a/150974/4190785 - var tcpListener = new TcpListener(IPAddress.Loopback, 0); - tcpListener.Start(); - var port = ((IPEndPoint) tcpListener.LocalEndpoint).Port; - tcpListener.Stop(); - return port; - } - - public static string GetSqlConnectionString() - { - return new SqlConnectionStringBuilder() - { - ConnectionString = "Server=db;Database=FlightDB;User ID=sa;Password=@Aa123456" - }.ToString(); - } -} diff --git a/src/Services/Flight/tests/Integration.Test.csproj b/src/Services/Flight/tests/Integration.Test.csproj index ce02b74..6d79eb8 100644 --- a/src/Services/Flight/tests/Integration.Test.csproj +++ b/src/Services/Flight/tests/Integration.Test.csproj @@ -6,29 +6,29 @@ - + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - - - - - - - + + + + + + + + - + diff --git a/src/Services/Flight/tests/TestFixture.cs b/src/Services/Flight/tests/TestFixture.cs index 1fa5b94..36c7fc8 100644 --- a/src/Services/Flight/tests/TestFixture.cs +++ b/src/Services/Flight/tests/TestFixture.cs @@ -1,14 +1,25 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using BuildingBlocks.Domain.Model; using Flight.Data; +using MassTransit; +using MassTransit.Testing; using MediatR; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Moq; using Respawn; using Xunit; +using Xunit.Abstractions; namespace Integration.Test; @@ -18,51 +29,72 @@ public class SliceFixtureCollection : ICollectionFixture } // ref: https://github.com/jbogard/ContosoUniversityDotNetCore-Pages/blob/master/ContosoUniversity.IntegrationTests/SliceFixture.cs +// ref: https://github.com/MassTransit/MassTransit/blob/00d6992286911a437b63b93c89a56e920b053c11/src/MassTransit.TestFramework/InMemoryTestFixture.cs +// ref: https://wrapt.dev/blog/building-an-event-driven-dotnet-application-integration-testing public class TestFixture : IAsyncLifetime { private readonly Checkpoint _checkpoint; private readonly IConfiguration _configuration; private readonly WebApplicationFactory _factory; private readonly IServiceScopeFactory _scopeFactory; + private static InMemoryTestHarness _harness; + public ITestOutputHelper Output { get; set; } public TestFixture() { - var factory = FlightTestApplicationFactory(); + _factory = FlightTestApplicationFactory(); - _configuration = factory.Services.GetRequiredService(); - _scopeFactory = factory.Services.GetRequiredService(); + _configuration = _factory.Services.GetRequiredService(); + _scopeFactory = _factory.Services.GetRequiredService(); _checkpoint = new Checkpoint(); } + public WebApplicationFactory FlightTestApplicationFactory() + { + Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "test"); + + return new WebApplicationFactory() + .WithWebHostBuilder(builder => + { + builder.ConfigureTestServices((services) => + { + services.RemoveAll(typeof(IHostedService)); + }); + + builder.ConfigureServices(services => + { + builder.ConfigureLogging(logging => + { + logging.ClearProviders(); // Remove other loggers + }); + + var httpContextAccessorService = services.FirstOrDefault(d => + d.ServiceType == typeof(IHttpContextAccessor)); + + services.Remove(httpContextAccessorService); + services.AddSingleton(_ => Mock.Of()); + + services.AddScoped(); + var provider = services.BuildServiceProvider(); + var serviceScopeFactory = provider.GetService(); + + // MassTransit Start Setup -- Do Not Delete Comment + _harness = serviceScopeFactory?.CreateScope().ServiceProvider.GetRequiredService(); + _harness?.Start().GetAwaiter().GetResult(); + }); + }); + } public Task InitializeAsync() { return _checkpoint.Reset(_configuration.GetConnectionString("DefaultConnection")); } - public Task DisposeAsync() + public async Task DisposeAsync() { - _factory?.Dispose(); - return Task.CompletedTask; - } - - public WebApplicationFactory FlightTestApplicationFactory() - { - return new WebApplicationFactory() - .WithWebHostBuilder(builder => - { - builder.ConfigureAppConfiguration((_, configBuilder) => - { - configBuilder.AddInMemoryCollection(new Dictionary - { - { - "ConnectionStrings:DefaultConnection", - "Server=db;Database=FlightDB;User ID=sa;Password=@Aa123456" - } - }); - }); - }); + await _harness.Stop(); + await _factory.DisposeAsync(); } public async Task ExecuteScopeAsync(Func action) @@ -227,4 +259,65 @@ public class TestFixture : IAsyncLifetime return mediator.Send(request); }); } + + + // MassTransit Methods -- Do Not Delete Comment + /// + /// Publishes a message to the bus, and waits for the specified response. + /// + /// The message that should be published. + /// The message that should be published. + public static async Task PublishMessage(object message) + where TMessage : class + { + await _harness.Bus.Publish(message); + } + + /// + /// Confirm if there was a fault when publishing for this harness. + /// + /// The message that should be published. + /// A boolean of true if there was a fault for a message of the given type when published. + public Task IsFaultyPublished() + where TMessage : class + { + return _harness.Published.Any>(); + } + + /// + /// Confirm that a message has been published for this harness. + /// + /// The message that should be published. + /// A boolean of true if a message of the given type has been published. + public Task IsPublished() + where TMessage : class + { + return _harness.Published.Any(); + } + + /// + /// Confirm that a message has been consumed for this harness. + /// + /// The message that should be consumed. + /// A boolean of true if a message of the given type has been consumed. + public Task IsConsumed() + where TMessage : class + { + return _harness.Consumed.Any(); + } + + /// + /// The desired consumer consumed the message. + /// + /// The message that should be consumed. + /// The consumer of the message. + /// A boolean of true if a message of the given type has been consumed by the given consumer. + public Task IsConsumed() + where TMessage : class + where TConsumedBy : class, IConsumer + { + using var scope = _scopeFactory.CreateScope(); + var consumerHarness = scope.ServiceProvider.GetRequiredService>(); + return consumerHarness.Consumed.Any(); + } } diff --git a/src/Services/Identity/src/Identity.Api/Program.cs b/src/Services/Identity/src/Identity.Api/Program.cs index 5c76b8c..2e54324 100644 --- a/src/Services/Identity/src/Identity.Api/Program.cs +++ b/src/Services/Identity/src/Identity.Api/Program.cs @@ -45,7 +45,7 @@ builder.Services.AddScoped(); builder.Services.AddTransient(); builder.Services.AddTransient(); -builder.Services.AddCustomMassTransit(typeof(IdentityRoot).Assembly); +builder.Services.AddCustomMassTransit(typeof(IdentityRoot).Assembly, env); builder.Services.AddCustomOpenTelemetry(); builder.Services.AddIdentityServer(env); diff --git a/src/Services/Identity/src/Identity.Api/appsettings.docker.json b/src/Services/Identity/src/Identity.Api/appsettings.docker.json index e431598..9123110 100644 --- a/src/Services/Identity/src/Identity.Api/appsettings.docker.json +++ b/src/Services/Identity/src/Identity.Api/appsettings.docker.json @@ -1,7 +1,7 @@ { "App": "Identity-Service", "ConnectionStrings": { - "IdentityConnection": "Server=db;Database=IdentityDB;User ID=sa;Password=@Aa123456" + "DefaultConnection": "Server=db;Database=IdentityDB;User ID=sa;Password=@Aa123456" }, "RabbitMq": { "HostName": "rabbitmq", diff --git a/src/Services/Passenger/src/Passenger.Api/Program.cs b/src/Services/Passenger/src/Passenger.Api/Program.cs index c36bb70..183244c 100644 --- a/src/Services/Passenger/src/Passenger.Api/Program.cs +++ b/src/Services/Passenger/src/Passenger.Api/Program.cs @@ -22,6 +22,7 @@ using Serilog; var builder = WebApplication.CreateBuilder(args); var configuration = builder.Configuration; +var env = builder.Environment; var appOptions = builder.Services.GetOptions("AppOptions"); Console.WriteLine(FiggleFonts.Standard.Render(appOptions.Name)); @@ -41,7 +42,7 @@ builder.Services.AddHttpContextAccessor(); builder.Services.AddTransient(); builder.Services.AddTransient(); -builder.Services.AddCustomMassTransit(typeof(PassengerRoot).Assembly); +builder.Services.AddCustomMassTransit(typeof(PassengerRoot).Assembly, env); builder.Services.AddCustomOpenTelemetry(); builder.Services.AddGrpc(options => { diff --git a/src/Services/Passenger/src/Passenger.Api/appsettings.docker.json b/src/Services/Passenger/src/Passenger.Api/appsettings.docker.json index 94eac04..d7bea44 100644 --- a/src/Services/Passenger/src/Passenger.Api/appsettings.docker.json +++ b/src/Services/Passenger/src/Passenger.Api/appsettings.docker.json @@ -1,7 +1,7 @@ { "App": "Passenger-Service", "ConnectionStrings": { - "PassengerConnection": "Server=db;Database=PassengerDB;User ID=sa;Password=@Aa123456" + "DefaultConnection": "Server=db;Database=PassengerDB;User ID=sa;Password=@Aa123456" }, "Jwt": { "Authority": "https://localhost:5005",