Skip to content

Commit

Permalink
feat(wfs): add geolocation view
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneD committed Oct 23, 2024
1 parent aaf27ff commit 34334b2
Show file tree
Hide file tree
Showing 3 changed files with 234 additions and 4 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

#nullable disable

namespace StreetNameRegistry.Projections.Wfs.Migrations
{
/// <inheritdoc />
public partial class AddGeolocationView : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(name: "geolocation");
migrationBuilder.Sql("ALTER AUTHORIZATION ON SCHEMA::geolocation TO wms");
migrationBuilder.Sql(@"
CREATE VIEW geolocation.StreetNameOsloGeolocationView WITH SCHEMABINDING AS
SELECT
CASE WHEN Removed = 1 THEN NULL ELSE CONCAT('https://data.vlaanderen.be/id/straatnaam/', [PersistentLocalId]) END as IDENTIFICATOR_ID
,CASE WHEN Removed = 1 THEN NULL ELSE 'https://data.vlaanderen.be/id/straatnaam' END as IDENTIFICATOR_NAAMRUIMTE
,CASE WHEN Removed = 1 THEN NULL ELSE [PersistentLocalId] END as IDENTIFICATOR_OBJECTID
,CASE WHEN Removed = 1 THEN NULL ELSE [VersionAsString] END as IDENTIFICATOR_VERSIEID
,CASE WHEN Removed = 1 THEN NULL ELSE [NisCode] END as GEMEENTE_OBJECTID
,CASE WHEN Removed = 1 THEN NULL ELSE [NameDutch] END as STRAATNAAM_NL
,CASE WHEN Removed = 1 THEN NULL ELSE [NameFrench] END as STRAATNAAM_FR
,CASE WHEN Removed = 1 THEN NULL ELSE [NameGerman] END as STRAATNAAM_DE
,CASE WHEN Removed = 1 THEN NULL ELSE [HomonymAdditionDutch] END as HOMONIEMTOEVOEGING_NL
,CASE WHEN Removed = 1 THEN NULL ELSE [HomonymAdditionFrench] END as HOMONIEMTOEVOEGING_FR
,CASE WHEN Removed = 1 THEN NULL ELSE [HomonymAdditionGerman] END as HOMONIEMTOEVOEGING_DE
,CASE WHEN Removed = 1 THEN NULL ELSE
CASE
WHEN [Status] = 0 THEN 'voorgesteld'
WHEN [Status] = 1 THEN 'inGebruik'
WHEN [Status] = 2 THEN 'gehistoreerd'
WHEN [Status] = 3 THEN 'afgekeurd'
END
END as STRAATNAAMSTATUS
,[Removed] as REMOVED
,[PersistentLocalId] as [msgkey]
FROM [wfs.streetname].[StreetNameHelperV2]");

migrationBuilder.Sql("CREATE UNIQUE CLUSTERED INDEX IX_StreetNameGeolocationView_ObjectId ON [geolocation].[StreetNameOsloGeolocationView] ([msgkey])");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("DROP VIEW geolocation.StreetNameOsloGeolocationView;");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.3")
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

modelBuilder.Entity("Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner.ProjectionStates.ProjectionStateItem", b =>
{
Expand All @@ -41,8 +41,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasKey("Name");

SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Name"));

b.ToTable("ProjectionStates", "wfs.streetname");
});

Expand Down

0 comments on commit 34334b2

Please sign in to comment.