Skip to content

Commit

Permalink
feat: add idempotencekeys to tables
Browse files Browse the repository at this point in the history
  • Loading branch information
pgallik committed Dec 8, 2023
1 parent f2c2e77 commit 88c9d8d
Show file tree
Hide file tree
Showing 10 changed files with 1,144 additions and 1 deletion.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Basisregisters.IntegrationDb.Schema.Migrations
{
public partial class add_idempotencekeys : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<long>(
name: "IdempotenceKey",
schema: "Integration",
table: "StreetNames",
type: "bigint",
nullable: true);

migrationBuilder.AddColumn<long>(
name: "IdempotenceKey",
schema: "Integration",
table: "PostInfo",
type: "bigint",
nullable: true);

migrationBuilder.AddColumn<long>(
name: "IdempotenceKey",
schema: "Integration",
table: "Parcels",
type: "bigint",
nullable: true);

migrationBuilder.AddColumn<long>(
name: "IdempotenceKey",
schema: "Integration",
table: "Municipalities",
type: "bigint",
nullable: true);

migrationBuilder.AddColumn<long>(
name: "IdempotenceKey",
schema: "Integration",
table: "BuildingUnits",
type: "bigint",
nullable: true);

migrationBuilder.AddColumn<long>(
name: "IdempotenceKey",
schema: "Integration",
table: "Buildings",
type: "bigint",
nullable: true);

migrationBuilder.AddColumn<long>(
name: "IdempotenceKey",
schema: "Integration",
table: "Addresses",
type: "bigint",
nullable: true);
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IdempotenceKey",
schema: "Integration",
table: "StreetNames");

migrationBuilder.DropColumn(
name: "IdempotenceKey",
schema: "Integration",
table: "PostInfo");

migrationBuilder.DropColumn(
name: "IdempotenceKey",
schema: "Integration",
table: "Parcels");

migrationBuilder.DropColumn(
name: "IdempotenceKey",
schema: "Integration",
table: "Municipalities");

migrationBuilder.DropColumn(
name: "IdempotenceKey",
schema: "Integration",
table: "BuildingUnits");

migrationBuilder.DropColumn(
name: "IdempotenceKey",
schema: "Integration",
table: "Buildings");

migrationBuilder.DropColumn(
name: "IdempotenceKey",
schema: "Integration",
table: "Addresses");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<string>("HouseNumber")
.HasColumnType("text");

b.Property<long?>("IdempotenceKey")
.HasColumnType("bigint");

b.Property<bool?>("IsOfficiallyAssigned")
.HasColumnType("boolean");

Expand Down Expand Up @@ -124,6 +127,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<string>("GeometryMethod")
.HasColumnType("text");

b.Property<long?>("IdempotenceKey")
.HasColumnType("bigint");

b.Property<bool>("IsRemoved")
.HasColumnType("boolean");

Expand Down Expand Up @@ -187,6 +193,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<bool?>("HasDeviation")
.HasColumnType("boolean");

b.Property<long?>("IdempotenceKey")
.HasColumnType("bigint");

b.Property<bool>("IsRemoved")
.HasColumnType("boolean");

Expand Down Expand Up @@ -239,6 +248,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<bool?>("FacilityLanguageGerman")
.HasColumnType("boolean");

b.Property<long?>("IdempotenceKey")
.HasColumnType("bigint");

b.Property<bool>("IsRemoved")
.HasColumnType("boolean");

Expand Down Expand Up @@ -310,6 +322,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<string>("Addresses")
.HasColumnType("text");

b.Property<long?>("IdempotenceKey")
.HasColumnType("bigint");

b.Property<bool>("IsRemoved")
.HasColumnType("boolean");

Expand Down Expand Up @@ -346,6 +361,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<string>("PostalCode")
.HasColumnType("text");

b.Property<long?>("IdempotenceKey")
.HasColumnType("bigint");

b.Property<string>("Namespace")
.HasColumnType("text");

Expand Down Expand Up @@ -539,6 +557,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<string>("HomonymAdditionGerman")
.HasColumnType("text");

b.Property<long?>("IdempotenceKey")
.HasColumnType("bigint");

b.Property<bool>("IsRemoved")
.HasColumnType("boolean");

Expand Down Expand Up @@ -594,6 +615,203 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.ToTable("StreetNames", "Integration");
});

modelBuilder.Entity("Basisregisters.IntegrationDb.Schema.Models.Views.ActiveAddressWithoutLinkedParcelOrBuildingUnits", b =>
{
b.Property<int>("AddressPersistentLocalId")
.HasColumnType("integer");

b.Property<int>("NisCode")
.HasColumnType("integer");

b.Property<DateTimeOffset>("Timestamp")
.HasColumnType("timestamp with time zone");

b.HasIndex("AddressPersistentLocalId");

b.HasIndex("NisCode");

b.ToView("ActiveAddressWithoutLinkedParcelOrBuildingUnits", "Integration");

b.ToSqlQuery("SELECT\r\n \"AddressPersistentLocalId\",\r\n \"NisCode\",\r\n \"Timestamp\"\r\n FROM \"Integration\".\"VIEW_ActiveAddressWithoutLinkedParcelOrBuildingUnit\" ");
});

modelBuilder.Entity("Basisregisters.IntegrationDb.Schema.Models.Views.ActiveAddressWithoutLinkedParcels", b =>
{
b.Property<int>("AddressPersistentLocalId")
.HasColumnType("integer");

b.Property<int>("NisCode")
.HasColumnType("integer");

b.Property<DateTimeOffset>("Timestamp")
.HasColumnType("timestamp with time zone");

b.HasIndex("AddressPersistentLocalId");

b.HasIndex("NisCode");

b.ToView("ActiveAddressWithoutLinkedParcels", "Integration");

b.ToSqlQuery("SELECT\r\n \"AddressPersistentLocalId\"\r\n ,\"NisCode\"\r\n ,\"Timestamp\"\r\n FROM \"Integration\".\"\r\n CREATE MATERIALIZED VIEW IF NOT EXISTS \"Integration\".\"VIEW_ActiveAddressWithoutLinkedParcels\" AS\r\n SELECT\r\n a.\"PersistentLocalId\" AS \"AddressPersistentLocalId\",\r\n a.\"NisCode\"::int,\r\n CURRENT_TIMESTAMP AS \"Timestamp\"\r\n\r\n FROM \"Integration\".\"Addresses\" AS a\r\n WHERE EXISTS (\r\n SELECT 1\r\n FROM \"Integration\".\"Addresses\" AS address\r\n LEFT JOIN \"Integration\".\"VIEW_ParcelAddressRelations\" AS parcelRelations\r\n ON address.\"PersistentLocalId\" = parcelRelations.\"AddressPersistentLocalId\"\r\n WHERE address.\"PersistentLocalId\" = a.\"PersistentLocalId\"\r\n AND parcelRelations.\"AddressPersistentLocalId\" IS NULL\r\n AND address.\"Status\" ILIKE 'inGebruik'\r\n AND address.\"IsRemoved\" = false\r\n )\r\n ORDER BY a.\"PersistentLocalId\"\r\n \" ");
});

modelBuilder.Entity("Basisregisters.IntegrationDb.Schema.Models.Views.ActiveStreetnameWithoutLinkedRoadSegments", b =>
{
b.Property<int>("NisCode")
.HasColumnType("integer");

b.Property<int>("StreetNamePersistentLocalId")
.HasColumnType("integer");

b.Property<DateTime>("Timestamp")
.HasColumnType("timestamp with time zone");

b.HasIndex("NisCode");

b.HasIndex("StreetNamePersistentLocalId");

b.ToView("ActiveStreetnameWithoutLinkedRoadSegments", "Integration");

b.ToSqlQuery("\r\n SELECT\r\n \"StreetNamePersistentLocalId\",\r\n \"NisCode\",\r\n \"Timestamp\"\r\n FROM \"Integration\".\"VIEW_ActiveStreetnameWithoutLinkedRoadSegments\" ");
});

modelBuilder.Entity("Basisregisters.IntegrationDb.Schema.Models.Views.AddressesLinkedToMultipleBuildingUnits", b =>
{
b.Property<int>("AddressPersistentLocalId")
.HasColumnType("integer");

b.Property<int>("LinkedBuildingUnitCount")
.HasColumnType("integer");

b.Property<int>("NisCode")
.HasColumnType("integer");

b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");

b.Property<DateTime>("Timestamp")
.HasColumnType("timestamp with time zone");

b.HasIndex("AddressPersistentLocalId");

b.HasIndex("Status");

b.ToView("AddressesLinkedToMultipleBuildingUnits", "Integration");

b.ToSqlQuery("\r\n SELECT\r\n \"AddressPersistentLocalId\",\r\n \"LinkedBuildingUnitCount\",\r\n \"NisCode\",\r\n \"Timestamp\"\r\n FROM \"Integration\".\"VIEW_AddressesLinkedToMultipleBuildingUnits\" ");
});

modelBuilder.Entity("Basisregisters.IntegrationDb.Schema.Models.Views.AddressesWithMultipleLinks", b =>
{
b.Property<int>("AddressPersistentLocalId")
.HasColumnType("integer");

b.Property<bool>("IsRemoved")
.HasColumnType("boolean");

b.Property<int>("LinkedBuildingUnitCount")
.HasColumnType("integer");

b.Property<int>("LinkedParcelCount")
.HasColumnType("integer");

b.Property<int>("NisCode")
.HasColumnType("integer");

b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");

b.Property<DateTime>("Timestamp")
.HasColumnType("timestamp with time zone");

b.HasIndex("AddressPersistentLocalId");

b.HasIndex("NisCode");

b.ToView("AddressesWithMultipleLinks", "Integration");

b.ToSqlQuery("\r\n SELECT\r\n \"AddressPersistentLocalId\",\r\n \"Status\",\r\n \"IsRemoved\",\r\n \"LinkedBuildingUnitCount\",\r\n \"LinkedParcelCount\",\r\n \"NisCode\",\r\n \"CURRENT_TIMESTAMP AS \"Timestamp\"\r\n FROM \"Integration\".\"VIEW_AddressesWithMultipleLinks\" ");
});

modelBuilder.Entity("Basisregisters.IntegrationDb.Schema.Models.Views.AddressesWithoutPostalCode", b =>
{
b.Property<int>("AddressPersistentLocalId")
.HasColumnType("integer");

b.Property<int>("NisCode")
.HasColumnType("integer");

b.Property<DateTime>("Timestamp")
.HasColumnType("timestamp with time zone");

b.HasIndex("AddressPersistentLocalId");

b.ToView("AddressesWithoutPostalCode", "Integration");

b.ToSqlQuery("\r\n SELECT\r\n \"AddressPersistentLocalId\",\r\n \"NisCode\",\r\n \"Timestamp\"\r\n FROM \"Integration\".\"VIEW_AddressesWithoutPostalCode\" ");
});

modelBuilder.Entity("Basisregisters.IntegrationDb.Schema.Models.Views.BuildingUnitAddressRelations", b =>
{
b.Property<string>("AddressPersistentLocalId")
.IsRequired()
.HasColumnType("text");

b.Property<int>("BuildingUnitPersistentLocalId")
.HasColumnType("integer");

b.HasIndex("AddressPersistentLocalId");

b.HasIndex("BuildingUnitPersistentLocalId");

b.ToView("BuildingUnitAddressRelations", "Integration");

b.ToSqlQuery("\r\n SELECT\r\n \"BuildingUnitPersistentLocalId\",\r\n \"AddressPersistentLocalId\"\r\n FROM \"Integration\".\"VIEW_BuildingUnitAddressRelations\" ");
});

modelBuilder.Entity("Basisregisters.IntegrationDb.Schema.Models.Views.ParcelAddressRelations", b =>
{
b.Property<int?>("AddressPersistentLocalId")
.HasColumnType("integer");

b.Property<string>("CaPaKey")
.IsRequired()
.HasColumnType("text");

b.Property<DateTime>("Timestamp")
.HasColumnType("timestamp with time zone");

b.HasIndex("AddressPersistentLocalId");

b.HasIndex("CaPaKey");

b.ToView("ParcelAddressRelations", "Integration");

b.ToSqlQuery("\r\n SELECT\r\n \"CaPaKey\",\r\n \"AddressPersistentLocalId\"\r\n FROM \"Integration\".\"VIEW_ParcelAddressRelations\" ");
});

modelBuilder.Entity("Basisregisters.IntegrationDb.Schema.Models.Views.ParcelsLinkedToMultipleAddresses", b =>
{
b.Property<string>("CaPaKey")
.IsRequired()
.HasColumnType("text");

b.Property<int>("LinkedAddressCount")
.HasColumnType("integer");

b.Property<int>("NisCode")
.HasColumnType("integer");

b.Property<DateTime>("Timestamp")
.HasColumnType("timestamp with time zone");

b.ToView("ParcelsLinkedToMultipleAddresses", "Integration");

b.ToSqlQuery("\r\n SELECT\r\n \"CaPaKey\",\r\n \"NisCode\",\r\n \"LinkedAddressCount\"\r\n FROM \"Integration\".\"VIEW_ParcelsLinkedToMultipleAddresses\" ");
});
#pragma warning restore 612, 618
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Basisregisters.IntegrationDb.Schema/Models/Address.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class Address
public string? Namespace { get; set; }
public string? VersionString { get; set; }
public DateTimeOffset? VersionTimestamp { get; set; }
public long? IdempotenceKey { get; set; }

public Address()
{ }
Expand Down
1 change: 1 addition & 0 deletions src/Basisregisters.IntegrationDb.Schema/Models/Building.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class Building
public string? Namespace { get; set; }
public string? VersionString { get; set; }
public DateTimeOffset? VersionTimestamp { get; set; }
public long? IdempotenceKey { get; set; }

public Building()
{ }
Expand Down
Loading

0 comments on commit 88c9d8d

Please sign in to comment.