diff --git a/src/ParcelRegistry.Projections.Integration/Migrations/20241022065609_FixParcelVersionTableName.Designer.cs b/src/ParcelRegistry.Projections.Integration/Migrations/20241022065609_FixParcelVersionTableName.Designer.cs new file mode 100644 index 00000000..baef4b1c --- /dev/null +++ b/src/ParcelRegistry.Projections.Integration/Migrations/20241022065609_FixParcelVersionTableName.Designer.cs @@ -0,0 +1,281 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using NetTopologySuite.Geometries; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using ParcelRegistry.Projections.Integration; + +#nullable disable + +namespace ParcelRegistry.Projections.Integration.Migrations +{ + [DbContext(typeof(IntegrationContext))] + [Migration("20241022065609_FixParcelVersionTableName")] + partial class FixParcelVersionTableName + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "postgis"); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner.ProjectionStates.ProjectionStateItem", b => + { + b.Property("Name") + .HasColumnType("text"); + + b.Property("DesiredState") + .HasColumnType("text"); + + b.Property("DesiredStateChangedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ErrorMessage") + .HasColumnType("text"); + + b.Property("Position") + .HasColumnType("bigint"); + + b.HasKey("Name"); + + b.ToTable("ProjectionStates", "integration_parcel"); + }); + + modelBuilder.Entity("ParcelRegistry.Projections.Integration.ParcelLatestItem.ParcelLatestItem", b => + { + b.Property("ParcelId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("parcel_id"); + + b.Property("CaPaKey") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar") + .HasColumnName("capakey"); + + b.Property("Geometry") + .IsRequired() + .HasColumnType("geometry") + .HasColumnName("geometry"); + + b.Property("IsRemoved") + .HasColumnType("boolean") + .HasColumnName("is_removed"); + + b.Property("Namespace") + .IsRequired() + .HasColumnType("text") + .HasColumnName("namespace"); + + b.Property("OsloStatus") + .IsRequired() + .HasColumnType("text") + .HasColumnName("oslo_status"); + + b.Property("Puri") + .IsRequired() + .HasColumnType("text") + .HasColumnName("puri"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text") + .HasColumnName("status"); + + b.Property("VersionAsString") + .IsRequired() + .HasColumnType("text") + .HasColumnName("version_as_string"); + + b.Property("VersionTimestampAsDateTimeOffset") + .HasColumnType("timestamp with time zone") + .HasColumnName("version_timestamp"); + + b.HasKey("ParcelId"); + + b.HasIndex("CaPaKey"); + + b.HasIndex("Geometry"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Geometry"), "GIST"); + + b.HasIndex("IsRemoved"); + + b.HasIndex("OsloStatus"); + + b.HasIndex("Status"); + + b.HasIndex("IsRemoved", "Status"); + + b.ToTable("parcel_latest_items", "integration_parcel"); + }); + + modelBuilder.Entity("ParcelRegistry.Projections.Integration.ParcelLatestItem.ParcelLatestItemAddress", b => + { + b.Property("ParcelId") + .HasColumnType("uuid") + .HasColumnName("parcel_id"); + + b.Property("AddressPersistentLocalId") + .HasColumnType("integer") + .HasColumnName("address_persistent_local_id"); + + b.Property("CaPaKey") + .IsRequired() + .HasColumnType("text") + .HasColumnName("capakey"); + + b.Property("Count") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.HasKey("ParcelId", "AddressPersistentLocalId"); + + b.HasIndex("AddressPersistentLocalId"); + + b.HasIndex("CaPaKey"); + + b.HasIndex("ParcelId"); + + b.ToTable("parcel_latest_item_addresses", "integration_parcel"); + }); + + modelBuilder.Entity("ParcelRegistry.Projections.Integration.ParcelVersion.ParcelVersion", b => + { + b.Property("Position") + .HasColumnType("bigint") + .HasColumnName("position"); + + b.Property("ParcelId") + .HasColumnType("uuid") + .HasColumnName("parcel_id"); + + b.Property("CaPaKey") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar") + .HasColumnName("capakey"); + + b.Property("CreatedOnAsString") + .IsRequired() + .HasColumnType("text") + .HasColumnName("created_on_as_string"); + + b.Property("CreatedOnTimestampAsDateTimeOffset") + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on_timestamp"); + + b.Property("Geometry") + .HasColumnType("geometry") + .HasColumnName("geometry"); + + b.Property("IsRemoved") + .HasColumnType("boolean") + .HasColumnName("is_removed"); + + b.Property("Namespace") + .IsRequired() + .HasColumnType("text") + .HasColumnName("namespace"); + + b.Property("OsloStatus") + .HasColumnType("text") + .HasColumnName("oslo_status"); + + b.Property("Puri") + .IsRequired() + .HasColumnType("text") + .HasColumnName("puri"); + + b.Property("Status") + .HasColumnType("text") + .HasColumnName("status"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text") + .HasColumnName("type"); + + b.Property("VersionAsString") + .IsRequired() + .HasColumnType("text") + .HasColumnName("version_as_string"); + + b.Property("VersionTimestampAsDateTimeOffset") + .HasColumnType("timestamp with time zone") + .HasColumnName("version_timestamp"); + + b.HasKey("Position", "ParcelId"); + + b.HasIndex("CaPaKey"); + + b.HasIndex("Geometry"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Geometry"), "GIST"); + + b.HasIndex("IsRemoved"); + + b.HasIndex("OsloStatus"); + + b.HasIndex("ParcelId"); + + b.HasIndex("Status"); + + b.HasIndex("Type"); + + b.HasIndex("VersionTimestampAsDateTimeOffset"); + + b.ToTable("parcel_versions", "integration_parcel"); + }); + + modelBuilder.Entity("ParcelRegistry.Projections.Integration.ParcelVersion.ParcelVersionAddress", b => + { + b.Property("Position") + .HasColumnType("bigint") + .HasColumnName("position"); + + b.Property("ParcelId") + .HasColumnType("uuid") + .HasColumnName("parcel_id"); + + b.Property("AddressPersistentLocalId") + .HasColumnType("integer") + .HasColumnName("address_persistent_local_id"); + + b.Property("CaPaKey") + .IsRequired() + .HasColumnType("text") + .HasColumnName("capakey"); + + b.Property("Count") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1) + .HasColumnName("count"); + + b.HasKey("Position", "ParcelId", "AddressPersistentLocalId"); + + b.HasIndex("AddressPersistentLocalId"); + + b.HasIndex("CaPaKey"); + + b.HasIndex("ParcelId"); + + b.HasIndex("Position"); + + b.ToTable("parcel_version_addresses", "integration_parcel"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/ParcelRegistry.Projections.Integration/Migrations/20241022065609_FixParcelVersionTableName.cs b/src/ParcelRegistry.Projections.Integration/Migrations/20241022065609_FixParcelVersionTableName.cs new file mode 100644 index 00000000..5c6d5c6b --- /dev/null +++ b/src/ParcelRegistry.Projections.Integration/Migrations/20241022065609_FixParcelVersionTableName.cs @@ -0,0 +1,148 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ParcelRegistry.Projections.Integration.Migrations +{ + /// + public partial class FixParcelVersionTableName : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_parcel_version", + schema: "integration_parcel", + table: "parcel_version"); + + migrationBuilder.RenameTable( + name: "parcel_version", + schema: "integration_parcel", + newName: "parcel_versions", + newSchema: "integration_parcel"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_version_version_timestamp", + schema: "integration_parcel", + table: "parcel_versions", + newName: "IX_parcel_versions_version_timestamp"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_version_type", + schema: "integration_parcel", + table: "parcel_versions", + newName: "IX_parcel_versions_type"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_version_status", + schema: "integration_parcel", + table: "parcel_versions", + newName: "IX_parcel_versions_status"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_version_parcel_id", + schema: "integration_parcel", + table: "parcel_versions", + newName: "IX_parcel_versions_parcel_id"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_version_oslo_status", + schema: "integration_parcel", + table: "parcel_versions", + newName: "IX_parcel_versions_oslo_status"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_version_is_removed", + schema: "integration_parcel", + table: "parcel_versions", + newName: "IX_parcel_versions_is_removed"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_version_geometry", + schema: "integration_parcel", + table: "parcel_versions", + newName: "IX_parcel_versions_geometry"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_version_capakey", + schema: "integration_parcel", + table: "parcel_versions", + newName: "IX_parcel_versions_capakey"); + + migrationBuilder.AddPrimaryKey( + name: "PK_parcel_versions", + schema: "integration_parcel", + table: "parcel_versions", + columns: new[] { "position", "parcel_id" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_parcel_versions", + schema: "integration_parcel", + table: "parcel_versions"); + + migrationBuilder.RenameTable( + name: "parcel_versions", + schema: "integration_parcel", + newName: "parcel_version", + newSchema: "integration_parcel"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_versions_version_timestamp", + schema: "integration_parcel", + table: "parcel_version", + newName: "IX_parcel_version_version_timestamp"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_versions_type", + schema: "integration_parcel", + table: "parcel_version", + newName: "IX_parcel_version_type"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_versions_status", + schema: "integration_parcel", + table: "parcel_version", + newName: "IX_parcel_version_status"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_versions_parcel_id", + schema: "integration_parcel", + table: "parcel_version", + newName: "IX_parcel_version_parcel_id"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_versions_oslo_status", + schema: "integration_parcel", + table: "parcel_version", + newName: "IX_parcel_version_oslo_status"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_versions_is_removed", + schema: "integration_parcel", + table: "parcel_version", + newName: "IX_parcel_version_is_removed"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_versions_geometry", + schema: "integration_parcel", + table: "parcel_version", + newName: "IX_parcel_version_geometry"); + + migrationBuilder.RenameIndex( + name: "IX_parcel_versions_capakey", + schema: "integration_parcel", + table: "parcel_version", + newName: "IX_parcel_version_capakey"); + + migrationBuilder.AddPrimaryKey( + name: "PK_parcel_version", + schema: "integration_parcel", + table: "parcel_version", + columns: new[] { "position", "parcel_id" }); + } + } +} diff --git a/src/ParcelRegistry.Projections.Integration/Migrations/IntegrationContextModelSnapshot.cs b/src/ParcelRegistry.Projections.Integration/Migrations/IntegrationContextModelSnapshot.cs index 24fad81d..a93df44d 100644 --- a/src/ParcelRegistry.Projections.Integration/Migrations/IntegrationContextModelSnapshot.cs +++ b/src/ParcelRegistry.Projections.Integration/Migrations/IntegrationContextModelSnapshot.cs @@ -232,7 +232,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("VersionTimestampAsDateTimeOffset"); - b.ToTable("parcel_version", "integration_parcel"); + b.ToTable("parcel_versions", "integration_parcel"); }); modelBuilder.Entity("ParcelRegistry.Projections.Integration.ParcelVersion.ParcelVersionAddress", b => diff --git a/src/ParcelRegistry.Projections.Integration/ParcelVersion/ParcelVersion.cs b/src/ParcelRegistry.Projections.Integration/ParcelVersion/ParcelVersion.cs index 7e444b12..b6d3880a 100644 --- a/src/ParcelRegistry.Projections.Integration/ParcelVersion/ParcelVersion.cs +++ b/src/ParcelRegistry.Projections.Integration/ParcelVersion/ParcelVersion.cs @@ -84,12 +84,12 @@ public ParcelVersion CloneAndApplyEventInfo(long newPosition, } } - public sealed class ParcelLatestItemConfiguration : IEntityTypeConfiguration + public sealed class ParcelVersionConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder - .ToTable("parcel_version", Schema.Integration) + .ToTable("parcel_versions", Schema.Integration) .HasKey(parcel => new { parcel.Position, parcel.ParcelId}); builder.Property(parcel => parcel.Position).ValueGeneratedNever();