diff --git a/src/Services/Flight/src/Flight/Data/Configurations/FlightConfiguration.cs b/src/Services/Flight/src/Flight/Data/Configurations/FlightConfiguration.cs index ea0a176..a06abe2 100644 --- a/src/Services/Flight/src/Flight/Data/Configurations/FlightConfiguration.cs +++ b/src/Services/Flight/src/Flight/Data/Configurations/FlightConfiguration.cs @@ -48,12 +48,6 @@ public class FlightConfiguration : IEntityTypeConfiguration d.ArriveAirportId); - //builder - // .HasOne() - // .WithMany() - // .HasForeignKey(d => d.DepartureAirportId.Value) - // .HasForeignKey(a => a.ArriveAirportId.Value); - builder.OwnsOne( x => x.DurationMinutes, diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20230331144237_Init.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20230331144237_Init.Designer.cs deleted file mode 100644 index f60fc7d..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20230331144237_Init.Designer.cs +++ /dev/null @@ -1,303 +0,0 @@ -// -using System; -using Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - [Migration("20230331144237_Init")] - partial class Init - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("ManufacturingYear") - .HasColumnType("integer") - .HasColumnName("manufacturing_year"); - - b.Property("Model") - .HasColumnType("text") - .HasColumnName("model"); - - b.Property("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_aircraft"); - - b.ToTable("aircraft", (string)null); - }); - - modelBuilder.Entity("Flight.Airports.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("Address") - .HasColumnType("text") - .HasColumnName("address"); - - b.Property("Code") - .HasColumnType("text") - .HasColumnName("code"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_airport"); - - b.ToTable("airport", (string)null); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("aircraft_id"); - - b.Property("ArriveAirportId") - .HasColumnType("uuid") - .HasColumnName("arrive_airport_id"); - - b.Property("ArriveDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("arrive_date"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("DepartureAirportId") - .HasColumnType("uuid") - .HasColumnName("departure_airport_id"); - - b.Property("DepartureDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("departure_date"); - - b.Property("DurationMinutes") - .HasColumnType("numeric") - .HasColumnName("duration_minutes"); - - b.Property("FlightDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("flight_date"); - - b.Property("FlightNumber") - .HasColumnType("text") - .HasColumnName("flight_number"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Price") - .HasColumnType("numeric") - .HasColumnName("price"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("status"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_flight"); - - b.HasIndex("AircraftId") - .HasDatabaseName("ix_flight_aircraft_id"); - - b.HasIndex("ArriveAirportId") - .HasDatabaseName("ix_flight_arrive_airport_id"); - - b.ToTable("flight", (string)null); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("Class") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("class"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("flight_id"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("SeatNumber") - .HasColumnType("text") - .HasColumnName("seat_number"); - - b.Property("Type") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("type"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_seat"); - - b.HasIndex("FlightId") - .HasDatabaseName("ix_seat_flight_id"); - - b.ToTable("seat", (string)null); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.HasOne("Flight.Aircrafts.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_aircraft_aircraft_id"); - - b.HasOne("Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_airport_arrive_airport_id"); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.HasOne("Flight.Flights.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_seat_flight_flight_id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20230525075149_aircraftValueObjects.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20230525075149_aircraftValueObjects.Designer.cs deleted file mode 100644 index 55dd254..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20230525075149_aircraftValueObjects.Designer.cs +++ /dev/null @@ -1,363 +0,0 @@ -// -using System; -using Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - [Migration("20230525075149_aircraftValueObjects")] - partial class aircraftValueObjects - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_aircraft"); - - b.ToTable("aircraft", (string)null); - }); - - modelBuilder.Entity("Flight.Airports.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("Address") - .HasColumnType("text") - .HasColumnName("address"); - - b.Property("Code") - .HasColumnType("text") - .HasColumnName("code"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_airport"); - - b.ToTable("airport", (string)null); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("aircraft_id"); - - b.Property("ArriveAirportId") - .HasColumnType("uuid") - .HasColumnName("arrive_airport_id"); - - b.Property("ArriveDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("arrive_date"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("DepartureAirportId") - .HasColumnType("uuid") - .HasColumnName("departure_airport_id"); - - b.Property("DepartureDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("departure_date"); - - b.Property("DurationMinutes") - .HasColumnType("numeric") - .HasColumnName("duration_minutes"); - - b.Property("FlightDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("flight_date"); - - b.Property("FlightNumber") - .HasColumnType("text") - .HasColumnName("flight_number"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Price") - .HasColumnType("numeric") - .HasColumnName("price"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("status"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_flight"); - - b.HasIndex("AircraftId") - .HasDatabaseName("ix_flight_aircraft_id"); - - b.HasIndex("ArriveAirportId") - .HasDatabaseName("ix_flight_arrive_airport_id"); - - b.ToTable("flight", (string)null); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("Class") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("class"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("flight_id"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("SeatNumber") - .HasColumnType("text") - .HasColumnName("seat_number"); - - b.Property("Type") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("type"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_seat"); - - b.HasIndex("FlightId") - .HasDatabaseName("ix_seat_flight_id"); - - b.ToTable("seat", (string)null); - }); - - modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b => - { - b.OwnsOne("Flight.Aircrafts.Models.ValueObjects.ManufacturingYearValue", "ManufacturingYear", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(5) - .HasColumnType("integer") - .HasColumnName("manufacturing_year"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.OwnsOne("Flight.Aircrafts.Models.ValueObjects.ModelValue", "Model", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("model"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.OwnsOne("Flight.Aircrafts.Models.ValueObjects.NameValue", "Name", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.Navigation("ManufacturingYear"); - - b.Navigation("Model"); - - b.Navigation("Name"); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.HasOne("Flight.Aircrafts.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_flight_aircraft_aircraft_id"); - - b.HasOne("Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_airport_arrive_airport_id"); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.HasOne("Flight.Flights.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_seat_flight_flight_id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20230525075149_aircraftValueObjects.cs b/src/Services/Flight/src/Flight/Data/Migrations/20230525075149_aircraftValueObjects.cs deleted file mode 100644 index c08d4ca..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20230525075149_aircraftValueObjects.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Flight.Data.Migrations -{ - /// - public partial class aircraftValueObjects : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "fk_flight_aircraft_aircraft_id", - table: "flight"); - - migrationBuilder.AlterColumn( - name: "aircraft_id", - table: "flight", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn( - name: "name", - table: "aircraft", - type: "character varying(50)", - maxLength: 50, - nullable: true, - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "model", - table: "aircraft", - type: "character varying(50)", - maxLength: 50, - nullable: true, - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "manufacturing_year", - table: "aircraft", - type: "integer", - maxLength: 5, - nullable: true, - oldClrType: typeof(int), - oldType: "integer"); - - migrationBuilder.AddForeignKey( - name: "fk_flight_aircraft_aircraft_id", - table: "flight", - column: "aircraft_id", - principalTable: "aircraft", - principalColumn: "id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "fk_flight_aircraft_aircraft_id", - table: "flight"); - - migrationBuilder.AlterColumn( - name: "aircraft_id", - table: "flight", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "name", - table: "aircraft", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(50)", - oldMaxLength: 50, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "model", - table: "aircraft", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(50)", - oldMaxLength: 50, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "manufacturing_year", - table: "aircraft", - type: "integer", - nullable: false, - defaultValue: 0, - oldClrType: typeof(int), - oldType: "integer", - oldMaxLength: 5, - oldNullable: true); - - migrationBuilder.AddForeignKey( - name: "fk_flight_aircraft_aircraft_id", - table: "flight", - column: "aircraft_id", - principalTable: "aircraft", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20230609154649_AddValueObjectForSeat-Airport-Flight.cs b/src/Services/Flight/src/Flight/Data/Migrations/20230609154649_AddValueObjectForSeat-Airport-Flight.cs deleted file mode 100644 index ea25884..0000000 --- a/src/Services/Flight/src/Flight/Data/Migrations/20230609154649_AddValueObjectForSeat-Airport-Flight.cs +++ /dev/null @@ -1,391 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Flight.Data.Migrations -{ - /// - public partial class AddValueObjectForSeatAirportFlight : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "seat_number", - table: "seat", - type: "character varying(50)", - maxLength: 50, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "price", - table: "flight", - type: "numeric", - maxLength: 10, - nullable: true, - oldClrType: typeof(decimal), - oldType: "numeric"); - - migrationBuilder.AlterColumn( - name: "flight_number", - table: "flight", - type: "character varying(50)", - maxLength: 50, - nullable: true, - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "flight_date", - table: "flight", - type: "timestamp with time zone", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); - - migrationBuilder.AlterColumn( - name: "duration_minutes", - table: "flight", - type: "numeric", - maxLength: 50, - nullable: true, - oldClrType: typeof(decimal), - oldType: "numeric"); - - migrationBuilder.AlterColumn( - name: "departure_date", - table: "flight", - type: "timestamp with time zone", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); - - migrationBuilder.AlterColumn( - name: "departure_airport_id", - table: "flight", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn( - name: "arrive_date", - table: "flight", - type: "timestamp with time zone", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); - - migrationBuilder.AlterColumn( - name: "arrive_airport_id", - table: "flight", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn( - name: "aircraft_id", - table: "flight", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "name", - table: "airport", - type: "character varying(50)", - maxLength: 50, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "code", - table: "airport", - type: "character varying(50)", - maxLength: 50, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "address", - table: "airport", - type: "character varying(50)", - maxLength: 50, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "name", - table: "aircraft", - type: "character varying(50)", - maxLength: 50, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "character varying(50)", - oldMaxLength: 50, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "model", - table: "aircraft", - type: "character varying(50)", - maxLength: 50, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "character varying(50)", - oldMaxLength: 50, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "manufacturing_year", - table: "aircraft", - type: "integer", - maxLength: 5, - nullable: false, - defaultValue: 0, - oldClrType: typeof(int), - oldType: "integer", - oldMaxLength: 5, - oldNullable: true); - - migrationBuilder.CreateIndex( - name: "ix_flight_departure_airport_id", - table: "flight", - column: "departure_airport_id"); - - //migrationBuilder.AddForeignKey( - // name: "fk_flight_aircraft_aircraft_id", - // table: "flight", - // column: "aircraft_id", - // principalTable: "aircraft", - // principalColumn: "id", - // onDelete: ReferentialAction.Cascade); - - //migrationBuilder.AddForeignKey( - // name: "fk_flight_airport_arrive_airport_id", - // table: "flight", - // column: "arrive_airport_id", - // principalTable: "airport", - // principalColumn: "id"); - - //migrationBuilder.AddForeignKey( - // name: "fk_flight_airport_departure_airport_id", - // table: "flight", - // column: "departure_airport_id", - // principalTable: "airport", - // principalColumn: "id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "fk_flight_aircraft_aircraft_id", - table: "flight"); - - migrationBuilder.DropForeignKey( - name: "fk_flight_airport_arrive_airport_id", - table: "flight"); - - migrationBuilder.DropForeignKey( - name: "fk_flight_airport_departure_airport_id", - table: "flight"); - - migrationBuilder.DropIndex( - name: "ix_flight_departure_airport_id", - table: "flight"); - - migrationBuilder.AlterColumn( - name: "seat_number", - table: "seat", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(50)", - oldMaxLength: 50); - - migrationBuilder.AlterColumn( - name: "price", - table: "flight", - type: "numeric", - nullable: false, - defaultValue: 0m, - oldClrType: typeof(decimal), - oldType: "numeric", - oldMaxLength: 10, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "flight_number", - table: "flight", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(50)", - oldMaxLength: 50, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "flight_date", - table: "flight", - type: "timestamp with time zone", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "duration_minutes", - table: "flight", - type: "numeric", - nullable: false, - defaultValue: 0m, - oldClrType: typeof(decimal), - oldType: "numeric", - oldMaxLength: 50, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "departure_date", - table: "flight", - type: "timestamp with time zone", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "departure_airport_id", - table: "flight", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "arrive_date", - table: "flight", - type: "timestamp with time zone", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "arrive_airport_id", - table: "flight", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "aircraft_id", - table: "flight", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn( - name: "name", - table: "airport", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(50)", - oldMaxLength: 50); - - migrationBuilder.AlterColumn( - name: "code", - table: "airport", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(50)", - oldMaxLength: 50); - - migrationBuilder.AlterColumn( - name: "address", - table: "airport", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(50)", - oldMaxLength: 50); - - migrationBuilder.AlterColumn( - name: "name", - table: "aircraft", - type: "character varying(50)", - maxLength: 50, - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(50)", - oldMaxLength: 50); - - migrationBuilder.AlterColumn( - name: "model", - table: "aircraft", - type: "character varying(50)", - maxLength: 50, - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(50)", - oldMaxLength: 50); - - migrationBuilder.AlterColumn( - name: "manufacturing_year", - table: "aircraft", - type: "integer", - maxLength: 5, - nullable: true, - oldClrType: typeof(int), - oldType: "integer", - oldMaxLength: 5); - - migrationBuilder.AddForeignKey( - name: "fk_flight_aircraft_aircraft_id", - table: "flight", - column: "aircraft_id", - principalTable: "aircraft", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_flight_airport_arrive_airport_id", - table: "flight", - column: "arrive_airport_id", - principalTable: "airport", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20230609154649_AddValueObjectForSeat-Airport-Flight.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20230611213200_initial.Designer.cs similarity index 96% rename from src/Services/Flight/src/Flight/Data/Migrations/20230609154649_AddValueObjectForSeat-Airport-Flight.Designer.cs rename to src/Services/Flight/src/Flight/Data/Migrations/20230611213200_initial.Designer.cs index 0578cf9..3e0ddd9 100644 --- a/src/Services/Flight/src/Flight/Data/Migrations/20230609154649_AddValueObjectForSeat-Airport-Flight.Designer.cs +++ b/src/Services/Flight/src/Flight/Data/Migrations/20230611213200_initial.Designer.cs @@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace Flight.Data.Migrations { [DbContext(typeof(FlightDbContext))] - [Migration("20230609154649_AddValueObjectForSeat-Airport-Flight")] - partial class AddValueObjectForSeatAirportFlight + [Migration("20230611213200_initial")] + partial class initial { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -109,7 +109,7 @@ namespace Flight.Data.Migrations .HasColumnType("uuid") .HasColumnName("aircraft_id"); - b.Property("ArriveAirportId") + b.Property("ArriveAirportId") .HasColumnType("uuid") .HasColumnName("arrive_airport_id"); @@ -121,7 +121,7 @@ namespace Flight.Data.Migrations .HasColumnType("bigint") .HasColumnName("created_by"); - b.Property("DepartureAirportId") + b.Property("DepartureAirportId") .HasColumnType("uuid") .HasColumnName("departure_airport_id"); @@ -389,11 +389,15 @@ namespace Flight.Data.Migrations b.HasOne("Flight.Airports.Models.Airport", null) .WithMany() .HasForeignKey("ArriveAirportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() .HasConstraintName("fk_flight_airport_arrive_airport_id"); b.HasOne("Flight.Airports.Models.Airport", null) .WithMany() .HasForeignKey("DepartureAirportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() .HasConstraintName("fk_flight_airport_departure_airport_id"); b.OwnsOne("Flight.Flights.ValueObjects.ArriveDate", "ArriveDate", b1 => @@ -520,17 +524,23 @@ namespace Flight.Data.Migrations .HasConstraintName("fk_flight_flight_id"); }); - b.Navigation("ArriveDate"); + b.Navigation("ArriveDate") + .IsRequired(); - b.Navigation("DepartureDate"); + b.Navigation("DepartureDate") + .IsRequired(); - b.Navigation("DurationMinutes"); + b.Navigation("DurationMinutes") + .IsRequired(); - b.Navigation("FlightDate"); + b.Navigation("FlightDate") + .IsRequired(); - b.Navigation("FlightNumber"); + b.Navigation("FlightNumber") + .IsRequired(); - b.Navigation("Price"); + b.Navigation("Price") + .IsRequired(); }); modelBuilder.Entity("Flight.Seats.Models.Seat", b => diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20230331144237_Init.cs b/src/Services/Flight/src/Flight/Data/Migrations/20230611213200_initial.cs similarity index 84% rename from src/Services/Flight/src/Flight/Data/Migrations/20230331144237_Init.cs rename to src/Services/Flight/src/Flight/Data/Migrations/20230611213200_initial.cs index 7d7c5ec..2c1d574 100644 --- a/src/Services/Flight/src/Flight/Data/Migrations/20230331144237_Init.cs +++ b/src/Services/Flight/src/Flight/Data/Migrations/20230611213200_initial.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace Flight.Data.Migrations { /// - public partial class Init : Migration + public partial class initial : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -16,9 +16,9 @@ namespace Flight.Data.Migrations columns: table => new { id = table.Column(type: "uuid", nullable: false), - name = table.Column(type: "text", nullable: true), - model = table.Column(type: "text", nullable: true), - manufacturingyear = table.Column(name: "manufacturing_year", type: "integer", nullable: false), + name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + model = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + manufacturingyear = table.Column(name: "manufacturing_year", type: "integer", maxLength: 5, nullable: false), createdat = table.Column(name: "created_at", type: "timestamp with time zone", nullable: true), createdby = table.Column(name: "created_by", type: "bigint", nullable: true), lastmodified = table.Column(name: "last_modified", type: "timestamp with time zone", nullable: true), @@ -36,9 +36,9 @@ namespace Flight.Data.Migrations columns: table => new { id = table.Column(type: "uuid", nullable: false), - name = table.Column(type: "text", nullable: true), - address = table.Column(type: "text", nullable: true), - code = table.Column(type: "text", nullable: true), + name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + address = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), createdat = table.Column(name: "created_at", type: "timestamp with time zone", nullable: true), createdby = table.Column(name: "created_by", type: "bigint", nullable: true), lastmodified = table.Column(name: "last_modified", type: "timestamp with time zone", nullable: true), @@ -56,16 +56,16 @@ namespace Flight.Data.Migrations columns: table => new { id = table.Column(type: "uuid", nullable: false), - flightnumber = table.Column(name: "flight_number", type: "text", nullable: true), + flightnumber = table.Column(name: "flight_number", type: "character varying(50)", maxLength: 50, nullable: false), aircraftid = table.Column(name: "aircraft_id", type: "uuid", nullable: false), - departuredate = table.Column(name: "departure_date", type: "timestamp with time zone", nullable: false), departureairportid = table.Column(name: "departure_airport_id", type: "uuid", nullable: false), - arrivedate = table.Column(name: "arrive_date", type: "timestamp with time zone", nullable: false), arriveairportid = table.Column(name: "arrive_airport_id", type: "uuid", nullable: false), - durationminutes = table.Column(name: "duration_minutes", type: "numeric", nullable: false), - flightdate = table.Column(name: "flight_date", type: "timestamp with time zone", nullable: false), + durationminutes = table.Column(name: "duration_minutes", type: "numeric", maxLength: 50, nullable: false), status = table.Column(type: "text", nullable: false, defaultValue: "Unknown"), - price = table.Column(type: "numeric", nullable: false), + price = table.Column(type: "numeric", maxLength: 10, nullable: false), + arrivedate = table.Column(name: "arrive_date", type: "timestamp with time zone", nullable: false), + departuredate = table.Column(name: "departure_date", type: "timestamp with time zone", nullable: false), + flightdate = table.Column(name: "flight_date", type: "timestamp with time zone", nullable: false), createdat = table.Column(name: "created_at", type: "timestamp with time zone", nullable: true), createdby = table.Column(name: "created_by", type: "bigint", nullable: true), lastmodified = table.Column(name: "last_modified", type: "timestamp with time zone", nullable: true), @@ -88,6 +88,12 @@ namespace Flight.Data.Migrations principalTable: "airport", principalColumn: "id", onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_flight_airport_departure_airport_id", + column: x => x.departureairportid, + principalTable: "airport", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( @@ -95,7 +101,7 @@ namespace Flight.Data.Migrations columns: table => new { id = table.Column(type: "uuid", nullable: false), - seatnumber = table.Column(name: "seat_number", type: "text", nullable: true), + seatnumber = table.Column(name: "seat_number", type: "character varying(50)", maxLength: 50, nullable: false), type = table.Column(type: "text", nullable: false, defaultValue: "Unknown"), @class = table.Column(name: "class", type: "text", nullable: false, defaultValue: "Unknown"), flightid = table.Column(name: "flight_id", type: "uuid", nullable: false), @@ -127,6 +133,11 @@ namespace Flight.Data.Migrations table: "flight", column: "arrive_airport_id"); + migrationBuilder.CreateIndex( + name: "ix_flight_departure_airport_id", + table: "flight", + column: "departure_airport_id"); + migrationBuilder.CreateIndex( name: "ix_seat_flight_id", table: "seat", diff --git a/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs b/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs index 11fb2cd..26192d8 100644 --- a/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs +++ b/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs @@ -106,7 +106,7 @@ namespace Flight.Data.Migrations .HasColumnType("uuid") .HasColumnName("aircraft_id"); - b.Property("ArriveAirportId") + b.Property("ArriveAirportId") .HasColumnType("uuid") .HasColumnName("arrive_airport_id"); @@ -118,7 +118,7 @@ namespace Flight.Data.Migrations .HasColumnType("bigint") .HasColumnName("created_by"); - b.Property("DepartureAirportId") + b.Property("DepartureAirportId") .HasColumnType("uuid") .HasColumnName("departure_airport_id"); @@ -386,11 +386,15 @@ namespace Flight.Data.Migrations b.HasOne("Flight.Airports.Models.Airport", null) .WithMany() .HasForeignKey("ArriveAirportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() .HasConstraintName("fk_flight_airport_arrive_airport_id"); b.HasOne("Flight.Airports.Models.Airport", null) .WithMany() .HasForeignKey("DepartureAirportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() .HasConstraintName("fk_flight_airport_departure_airport_id"); b.OwnsOne("Flight.Flights.ValueObjects.ArriveDate", "ArriveDate", b1 => @@ -517,17 +521,23 @@ namespace Flight.Data.Migrations .HasConstraintName("fk_flight_flight_id"); }); - b.Navigation("ArriveDate"); + b.Navigation("ArriveDate") + .IsRequired(); - b.Navigation("DepartureDate"); + b.Navigation("DepartureDate") + .IsRequired(); - b.Navigation("DurationMinutes"); + b.Navigation("DurationMinutes") + .IsRequired(); - b.Navigation("FlightDate"); + b.Navigation("FlightDate") + .IsRequired(); - b.Navigation("FlightNumber"); + b.Navigation("FlightNumber") + .IsRequired(); - b.Navigation("Price"); + b.Navigation("Price") + .IsRequired(); }); modelBuilder.Entity("Flight.Seats.Models.Seat", b => diff --git a/src/Services/Flight/src/Flight/Data/readme.md b/src/Services/Flight/src/Flight/Data/readme.md index ffeca35..f47e679 100644 --- a/src/Services/Flight/src/Flight/Data/readme.md +++ b/src/Services/Flight/src/Flight/Data/readme.md @@ -1,2 +1,2 @@ -dotnet ef migrations add Init --context FlightDbContext -o "Data\Migrations" +dotnet ef migrations add initial --context FlightDbContext -o "Data\Migrations" dotnet ef database update --context FlightDbContext diff --git a/src/Services/Passenger/src/Passenger/Data/Migrations/20230331204805_initial.Designer.cs b/src/Services/Passenger/src/Passenger/Data/Migrations/20230331204805_initial.Designer.cs deleted file mode 100644 index dd13574..0000000 --- a/src/Services/Passenger/src/Passenger/Data/Migrations/20230331204805_initial.Designer.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Passenger.Data; - -#nullable disable - -namespace Passenger.Data.Migrations -{ - [DbContext(typeof(PassengerDbContext))] - [Migration("20230331204805_initial")] - partial class initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Passenger.Passengers.Models.Passenger", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("Age") - .HasColumnType("integer") - .HasColumnName("age"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property("PassengerType") - .HasColumnType("integer") - .HasColumnName("passenger_type"); - - b.Property("PassportNumber") - .HasColumnType("text") - .HasColumnName("passport_number"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_passenger"); - - b.ToTable("passenger", (string)null); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Services/Passenger/src/Passenger/Data/Migrations/20230524195049_AddValueObject.Designer.cs b/src/Services/Passenger/src/Passenger/Data/Migrations/20230524195049_AddValueObject.Designer.cs deleted file mode 100644 index f5359cc..0000000 --- a/src/Services/Passenger/src/Passenger/Data/Migrations/20230524195049_AddValueObject.Designer.cs +++ /dev/null @@ -1,148 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Passenger.Data; - -#nullable disable - -namespace Passenger.Data.Migrations -{ - [DbContext(typeof(PassengerDbContext))] - [Migration("20230524195049_AddValueObject")] - partial class AddValueObject - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Passenger.Passengers.Models.Passenger", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp without time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("PassengerType") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("passenger_type"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_passenger"); - - b.ToTable("passenger", (string)null); - }); - - modelBuilder.Entity("Passenger.Passengers.Models.Passenger", b => - { - b.OwnsOne("Passenger.Passengers.Models.ValueObjects.Age", "Age", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(3) - .HasColumnType("integer") - .HasColumnName("age"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.OwnsOne("Passenger.Passengers.Models.ValueObjects.Name", "Name", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.OwnsOne("Passenger.Passengers.Models.ValueObjects.PassportNumber", "PassportNumber", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("passport_number"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.Navigation("Age"); - - b.Navigation("Name"); - - b.Navigation("PassportNumber"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Services/Passenger/src/Passenger/Data/Migrations/20230524195049_AddValueObject.cs b/src/Services/Passenger/src/Passenger/Data/Migrations/20230524195049_AddValueObject.cs deleted file mode 100644 index 95f7654..0000000 --- a/src/Services/Passenger/src/Passenger/Data/Migrations/20230524195049_AddValueObject.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Passenger.Data.Migrations -{ - /// - public partial class AddValueObject : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "passport_number", - table: "passenger", - type: "character varying(10)", - maxLength: 10, - nullable: true, - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "passenger_type", - table: "passenger", - type: "text", - nullable: false, - defaultValue: "Unknown", - oldClrType: typeof(int), - oldType: "integer"); - - migrationBuilder.AlterColumn( - name: "name", - table: "passenger", - type: "character varying(50)", - maxLength: 50, - nullable: true, - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "last_modified", - table: "passenger", - type: "timestamp without time zone", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "created_at", - table: "passenger", - type: "timestamp without time zone", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "age", - table: "passenger", - type: "integer", - maxLength: 3, - nullable: true, - oldClrType: typeof(int), - oldType: "integer"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "passport_number", - table: "passenger", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(10)", - oldMaxLength: 10, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "passenger_type", - table: "passenger", - type: "integer", - nullable: false, - oldClrType: typeof(string), - oldType: "text", - oldDefaultValue: "Unknown"); - - migrationBuilder.AlterColumn( - name: "name", - table: "passenger", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(50)", - oldMaxLength: 50, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "last_modified", - table: "passenger", - type: "timestamp with time zone", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "created_at", - table: "passenger", - type: "timestamp with time zone", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "age", - table: "passenger", - type: "integer", - nullable: false, - defaultValue: 0, - oldClrType: typeof(int), - oldType: "integer", - oldMaxLength: 3, - oldNullable: true); - } - } -} diff --git a/src/Services/Passenger/src/Passenger/Data/Migrations/20230526085126_change-behavior.cs b/src/Services/Passenger/src/Passenger/Data/Migrations/20230526085126_change-behavior.cs deleted file mode 100644 index 954e4f6..0000000 --- a/src/Services/Passenger/src/Passenger/Data/Migrations/20230526085126_change-behavior.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Passenger.Data.Migrations -{ - /// - public partial class changebehavior : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "last_modified", - table: "passenger", - type: "timestamp with time zone", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "created_at", - table: "passenger", - type: "timestamp with time zone", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone", - oldNullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "last_modified", - table: "passenger", - type: "timestamp without time zone", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "created_at", - table: "passenger", - type: "timestamp without time zone", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone", - oldNullable: true); - } - } -} diff --git a/src/Services/Passenger/src/Passenger/Data/Migrations/20230526085126_change-behavior.Designer.cs b/src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.Designer.cs similarity index 91% rename from src/Services/Passenger/src/Passenger/Data/Migrations/20230526085126_change-behavior.Designer.cs rename to src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.Designer.cs index 83dc119..d471cb8 100644 --- a/src/Services/Passenger/src/Passenger/Data/Migrations/20230526085126_change-behavior.Designer.cs +++ b/src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.Designer.cs @@ -12,8 +12,8 @@ using Passenger.Data; namespace Passenger.Data.Migrations { [DbContext(typeof(PassengerDbContext))] - [Migration("20230526085126_change-behavior")] - partial class changebehavior + [Migration("20230611213031_initial")] + partial class initial { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -71,7 +71,7 @@ namespace Passenger.Data.Migrations modelBuilder.Entity("Passenger.Passengers.Models.Passenger", b => { - b.OwnsOne("Passenger.Passengers.Models.ValueObjects.Age", "Age", b1 => + b.OwnsOne("Passenger.Passengers.ValueObjects.Age", "Age", b1 => { b1.Property("PassengerId") .HasColumnType("uuid") @@ -92,7 +92,7 @@ namespace Passenger.Data.Migrations .HasConstraintName("fk_passenger_passenger_id"); }); - b.OwnsOne("Passenger.Passengers.Models.ValueObjects.Name", "Name", b1 => + b.OwnsOne("Passenger.Passengers.ValueObjects.Name", "Name", b1 => { b1.Property("PassengerId") .HasColumnType("uuid") @@ -114,7 +114,7 @@ namespace Passenger.Data.Migrations .HasConstraintName("fk_passenger_passenger_id"); }); - b.OwnsOne("Passenger.Passengers.Models.ValueObjects.PassportNumber", "PassportNumber", b1 => + b.OwnsOne("Passenger.Passengers.ValueObjects.PassportNumber", "PassportNumber", b1 => { b1.Property("PassengerId") .HasColumnType("uuid") @@ -138,9 +138,11 @@ namespace Passenger.Data.Migrations b.Navigation("Age"); - b.Navigation("Name"); + b.Navigation("Name") + .IsRequired(); - b.Navigation("PassportNumber"); + b.Navigation("PassportNumber") + .IsRequired(); }); #pragma warning restore 612, 618 } diff --git a/src/Services/Passenger/src/Passenger/Data/Migrations/20230331204805_initial.cs b/src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.cs similarity index 79% rename from src/Services/Passenger/src/Passenger/Data/Migrations/20230331204805_initial.cs rename to src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.cs index 76644b2..754a595 100644 --- a/src/Services/Passenger/src/Passenger/Data/Migrations/20230331204805_initial.cs +++ b/src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.cs @@ -16,10 +16,10 @@ namespace Passenger.Data.Migrations columns: table => new { id = table.Column(type: "uuid", nullable: false), - passportnumber = table.Column(name: "passport_number", type: "text", nullable: true), - name = table.Column(type: "text", nullable: true), - passengertype = table.Column(name: "passenger_type", type: "integer", nullable: false), - age = table.Column(type: "integer", nullable: false), + passportnumber = table.Column(name: "passport_number", type: "character varying(10)", maxLength: 10, nullable: false), + name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + passengertype = table.Column(name: "passenger_type", type: "text", nullable: false, defaultValue: "Unknown"), + age = table.Column(type: "integer", maxLength: 3, nullable: true), createdat = table.Column(name: "created_at", type: "timestamp with time zone", nullable: true), createdby = table.Column(name: "created_by", type: "bigint", nullable: true), lastmodified = table.Column(name: "last_modified", type: "timestamp with time zone", nullable: true), diff --git a/src/Services/Passenger/src/Passenger/Data/Migrations/PassengerDbContextModelSnapshot.cs b/src/Services/Passenger/src/Passenger/Data/Migrations/PassengerDbContextModelSnapshot.cs index 96a7468..122b184 100644 --- a/src/Services/Passenger/src/Passenger/Data/Migrations/PassengerDbContextModelSnapshot.cs +++ b/src/Services/Passenger/src/Passenger/Data/Migrations/PassengerDbContextModelSnapshot.cs @@ -68,7 +68,7 @@ namespace Passenger.Data.Migrations modelBuilder.Entity("Passenger.Passengers.Models.Passenger", b => { - b.OwnsOne("Passenger.Passengers.Models.ValueObjects.Age", "Age", b1 => + b.OwnsOne("Passenger.Passengers.ValueObjects.Age", "Age", b1 => { b1.Property("PassengerId") .HasColumnType("uuid") @@ -89,7 +89,7 @@ namespace Passenger.Data.Migrations .HasConstraintName("fk_passenger_passenger_id"); }); - b.OwnsOne("Passenger.Passengers.Models.ValueObjects.Name", "Name", b1 => + b.OwnsOne("Passenger.Passengers.ValueObjects.Name", "Name", b1 => { b1.Property("PassengerId") .HasColumnType("uuid") @@ -111,7 +111,7 @@ namespace Passenger.Data.Migrations .HasConstraintName("fk_passenger_passenger_id"); }); - b.OwnsOne("Passenger.Passengers.Models.ValueObjects.PassportNumber", "PassportNumber", b1 => + b.OwnsOne("Passenger.Passengers.ValueObjects.PassportNumber", "PassportNumber", b1 => { b1.Property("PassengerId") .HasColumnType("uuid") @@ -135,9 +135,11 @@ namespace Passenger.Data.Migrations b.Navigation("Age"); - b.Navigation("Name"); + b.Navigation("Name") + .IsRequired(); - b.Navigation("PassportNumber"); + b.Navigation("PassportNumber") + .IsRequired(); }); #pragma warning restore 612, 618 }