Index: Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/Migration_17.1_17.2.sql =================================================================== diff -u -rf8fd6922e67e0ba9843e79f0db217e914d1c3a8c -r7a06f1ab0de1530807326298377072709f29a119 --- Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/Migration_17.1_17.2.sql (.../Migration_17.1_17.2.sql) (revision f8fd6922e67e0ba9843e79f0db217e914d1c3a8c) +++ Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/Migration_17.1_17.2.sql (.../Migration_17.1_17.2.sql) (revision 7a06f1ab0de1530807326298377072709f29a119) @@ -49,7 +49,9 @@ [FailureMechanismEntityId], [Order], [Name], - CASE WHEN Suffix THEN [Id] || '(' || Suffix || ')' ELSE [Id] END as [Id], + CASE WHEN Suffix THEN [Name] || + SUBSTR(QUOTE(ZEROBLOB((SuffixPreLength + 1) / 2)), 3, SuffixPreLength) + || Suffix ELSE [Name] END as [Id], [X], [Y], [StructureNormalOrientation], @@ -76,12 +78,13 @@ [IdenticalApertures], [FailureProbabilityReparation], [InflowModelType] - FROM (SELECT *, (SELECT count(*) + FROM (SELECT *, MaxLength - LENGTH(NAME) as SuffixPreLength, (SELECT count(*) FROM [SOURCEPROJECT].ClosingStructureEntity WHERE HS.[ClosingStructureEntityId] > [ClosingStructureEntityId] AND HS.[Name] IS [Name] AND HS.[FailuremechanismEntityId] = [FailuremechanismEntityId]) as Suffix - FROM [SOURCEPROJECT].ClosingStructureEntity HS); + FROM [SOURCEPROJECT].ClosingStructureEntity HS + JOIN (SELECT MAX(LENGTH(Name)) as MaxLength FROM [SOURCEPROJECT].ClosingStructureEntity)); INSERT INTO ClosingStructuresCalculationEntity SELECT * FROM [SOURCEPROJECT].ClosingStructuresCalculationEntity; INSERT INTO ClosingStructuresFailureMechanismMetaEntity ( [ClosingStructuresFailureMechanismMetaEntityId], @@ -124,7 +127,9 @@ SELECT [ForeshoreProfileEntityId], [FailureMechanismEntityId], - CASE WHEN Suffix THEN [Name] || '(' || Suffix || ')' ELSE [Name] END as [Id], + CASE WHEN Suffix THEN [Name] || + SUBSTR(QUOTE(ZEROBLOB((SuffixPreLength + 1) / 2)), 3, SuffixPreLength) + || Suffix ELSE [Name] END as [Id], CASE WHEN Suffix THEN [Name] || '(' || Suffix || ')' ELSE [Name] END as [Name], [Orientation], [BreakWaterType], @@ -134,12 +139,13 @@ [Y], [X0], [Order] - FROM (SELECT *, (SELECT count(*) + FROM (SELECT *, MaxLength - LENGTH(NAME) as SuffixPreLength, (SELECT count(*) FROM [SOURCEPROJECT].ForeshoreProfileEntity WHERE FS.ForeshoreProfileEntityId > ForeshoreProfileEntityId AND FS.Name IS Name AND FS.FailuremechanismEntityId = FailuremechanismEntityId) as Suffix - FROM [SOURCEPROJECT].ForeshoreProfileEntity FS); + FROM [SOURCEPROJECT].ForeshoreProfileEntity FS + JOIN (SELECT MAX(LENGTH(Name)) as MaxLength FROM [SOURCEPROJECT].ForeshoreProfileEntity)); INSERT INTO GrassCoverErosionInwardsCalculationEntity SELECT * FROM [SOURCEPROJECT].GrassCoverErosionInwardsCalculationEntity; INSERT INTO GrassCoverErosionInwardsDikeHeightOutputEntity SELECT * FROM [SOURCEPROJECT].GrassCoverErosionInwardsDikeHeightOutputEntity; INSERT INTO GrassCoverErosionInwardsFailureMechanismMetaEntity SELECT * FROM [SOURCEPROJECT].GrassCoverErosionInwardsFailureMechanismMetaEntity; @@ -193,7 +199,9 @@ [FailureMechanismEntityId], [Order], [Name], - CASE WHEN Suffix THEN [Id] || '(' || Suffix || ')' ELSE [Id] END as [Id], + CASE WHEN Suffix THEN [Name] || + SUBSTR(QUOTE(ZEROBLOB((SuffixPreLength + 1) / 2)), 3, SuffixPreLength) + || Suffix ELSE [Name] END as [Id], [X], [Y], [StructureNormalOrientation], @@ -210,12 +218,13 @@ [StorageStructureAreaCoefficientOfVariation], [AllowedLevelIncreaseStorageMean], [AllowedLevelIncreaseStorageStandardDeviation] - FROM (SELECT *, (SELECT count(*) + FROM (SELECT *, MaxLength - LENGTH(NAME) as SuffixPreLength, (SELECT count(*) FROM [SOURCEPROJECT].HeightStructureEntity WHERE HS.[HeightStructureEntityId] > [HeightStructureEntityId] AND HS.[Name] IS [Name] AND HS.[FailuremechanismEntityId] = [FailuremechanismEntityId]) as Suffix - FROM [SOURCEPROJECT].HeightStructureEntity HS); + FROM [SOURCEPROJECT].HeightStructureEntity HS + JOIN (SELECT MAX(LENGTH(Name)) as MaxLength FROM [SOURCEPROJECT].HeightStructureEntity)); INSERT INTO HeightStructuresCalculationEntity SELECT * FROM [SOURCEPROJECT].HeightStructuresCalculationEntity; INSERT INTO HeightStructuresFailureMechanismMetaEntity ( [HeightStructuresFailureMechanismMetaEntityId], Index: Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/Migration_5_17.1.sql =================================================================== diff -u -r92c99376daee71036fa992b005fe0732e037ed82 -r7a06f1ab0de1530807326298377072709f29a119 --- Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/Migration_5_17.1.sql (.../Migration_5_17.1.sql) (revision 92c99376daee71036fa992b005fe0732e037ed82) +++ Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/Migration_5_17.1.sql (.../Migration_5_17.1.sql) (revision 7a06f1ab0de1530807326298377072709f29a119) @@ -32,7 +32,9 @@ SELECT [DikeProfileEntityId], [FailureMechanismEntityId], - CASE WHEN Suffix THEN [Name] || '(' || Suffix || ')' ELSE [Name] END as [Id], + CASE WHEN Suffix THEN [Name] || + SUBSTR(QUOTE(ZEROBLOB((SuffixPreLength + 1) / 2)), 3, SuffixPreLength) + || Suffix ELSE [Name] END as [Id], CASE WHEN Suffix THEN [Name] || '(' || Suffix || ')' ELSE [Name] END as [Name], [Orientation], [BreakWaterType], @@ -44,12 +46,13 @@ [Y], [X0], [Order] - FROM (SELECT *, (SELECT count(*) + FROM (SELECT *, MaxLength - LENGTH(NAME) as SuffixPreLength, (SELECT count(*) FROM [SOURCEPROJECT].DikeProfileEntity WHERE DP.DikeProfileEntityId > DikeProfileEntityId AND DP.Name IS Name AND DP.FailuremechanismEntityId = FailuremechanismEntityId) as Suffix - FROM [SOURCEPROJECT].DikeProfileEntity DP); + FROM [SOURCEPROJECT].DikeProfileEntity DP + JOIN (SELECT MAX(LENGTH(Name)) as MaxLength FROM [SOURCEPROJECT].DikeProfileEntity)); INSERT INTO DuneErosionSectionResultEntity SELECT * FROM [SOURCEPROJECT].DuneErosionSectionResultEntity; INSERT INTO FailureMechanismEntity SELECT * FROM [SOURCEPROJECT].FailureMechanismEntity; INSERT INTO FailureMechanismSectionEntity SELECT * FROM [SOURCEPROJECT].FailureMechanismSectionEntity; @@ -82,39 +85,39 @@ FROM [SOURCEPROJECT].ForeshoreProfileEntity; INSERT INTO GrassCoverErosionInwardsCalculationEntity ( [GrassCoverErosionInwardsCalculationEntityId], - [CalculationGroupEntityId], - [HydraulicLocationEntityId], - [DikeProfileEntityId], - [Order], - [Name], - [Comments], - [Orientation], - [CriticalFlowRateMean], - [CriticalFlowRateStandardDeviation], - [UseForeshore], - [DikeHeightCalculationType], - [DikeHeight], - [UseBreakWater], - [BreakWaterType], - [BreakWaterHeight], + [CalculationGroupEntityId], + [HydraulicLocationEntityId], + [DikeProfileEntityId], + [Order], + [Name], + [Comments], + [Orientation], + [CriticalFlowRateMean], + [CriticalFlowRateStandardDeviation], + [UseForeshore], + [DikeHeightCalculationType], + [DikeHeight], + [UseBreakWater], + [BreakWaterType], + [BreakWaterHeight], [OvertoppingRateCalculationType]) SELECT [GrassCoverErosionInwardsCalculationEntityId], - [CalculationGroupEntityId], - [HydraulicLocationEntityId], - [DikeProfileEntityId], - [Order], - [Name], - [Comments], - [Orientation], - [CriticalFlowRateMean], - [CriticalFlowRateStandardDeviation], - [UseForeshore], - [DikeHeightCalculationType], - [DikeHeight], - [UseBreakWater], - [BreakWaterType], - [BreakWaterHeight], + [CalculationGroupEntityId], + [HydraulicLocationEntityId], + [DikeProfileEntityId], + [Order], + [Name], + [Comments], + [Orientation], + [CriticalFlowRateMean], + [CriticalFlowRateStandardDeviation], + [UseForeshore], + [DikeHeightCalculationType], + [DikeHeight], + [UseBreakWater], + [BreakWaterType], + [BreakWaterHeight], 1 FROM [SOURCEPROJECT].GrassCoverErosionInwardsCalculationEntity; INSERT INTO GrassCoverErosionInwardsFailureMechanismMetaEntity ( Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo171IntegrationTest.cs =================================================================== diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -r7a06f1ab0de1530807326298377072709f29a119 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo171IntegrationTest.cs (.../MigrationTo171IntegrationTest.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo171IntegrationTest.cs (.../MigrationTo171IntegrationTest.cs) (revision 7a06f1ab0de1530807326298377072709f29a119) @@ -157,9 +157,8 @@ private static void AssertDikeProfiles(MigratedDatabaseReader reader) { const string validateDikeProfiles = - "SELECT " + - "(SELECT COUNT(DISTINCT(Name)) = COUNT() FROM DikeProfileEntity) " + - "AND (SELECT COUNT() = 0 FROM DikeProfileEntity WHERE Id != Name);"; + "SELECT COUNT(DISTINCT(Name)) = COUNT() " + + "AND COUNT(DISTINCT(Id)) = COUNT() FROM DikeProfileEntity"; reader.AssertReturnedDataIsValid(validateDikeProfiles); } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo172IntegrationTest.cs =================================================================== diff -u -rf8fd6922e67e0ba9843e79f0db217e914d1c3a8c -r7a06f1ab0de1530807326298377072709f29a119 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo172IntegrationTest.cs (.../MigrationTo172IntegrationTest.cs) (revision f8fd6922e67e0ba9843e79f0db217e914d1c3a8c) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo172IntegrationTest.cs (.../MigrationTo172IntegrationTest.cs) (revision 7a06f1ab0de1530807326298377072709f29a119) @@ -146,7 +146,7 @@ "FROM(" + "SELECT " + "CASE WHEN " + - "COUNT([ForeshoreProfileEntityId]) AND[ForeshoreProfileCollectionSourcePath] IS NULL " + + "COUNT([ForeshoreProfileEntityId]) AND [ForeshoreProfileCollectionSourcePath] IS NULL " + "OR " + "[ForeshoreProfileCollectionSourcePath] IS NOT NULL AND NOT COUNT([ForeshoreProfileEntityId]) " + "THEN 1 ELSE 0 END AS[IsInvalid] " + @@ -163,7 +163,7 @@ "FROM(" + "SELECT " + "CASE WHEN " + - "COUNT([ForeshoreProfileEntityId]) AND[ForeshoreProfileCollectionSourcePath] IS NULL " + + "COUNT([ForeshoreProfileEntityId]) AND [ForeshoreProfileCollectionSourcePath] IS NULL " + "OR " + "[ForeshoreProfileCollectionSourcePath] IS NOT NULL AND NOT COUNT([ForeshoreProfileEntityId]) " + "THEN 1 ELSE 0 END AS[IsInvalid] " + @@ -180,7 +180,7 @@ "FROM(" + "SELECT " + "CASE WHEN " + - "COUNT([ForeshoreProfileEntityId]) AND[ForeshoreProfileCollectionSourcePath] IS NULL " + + "COUNT([ForeshoreProfileEntityId]) AND [ForeshoreProfileCollectionSourcePath] IS NULL " + "OR " + "[ForeshoreProfileCollectionSourcePath] IS NOT NULL AND NOT COUNT([ForeshoreProfileEntityId]) " + "THEN 1 ELSE 0 END AS[IsInvalid] " + @@ -210,7 +210,7 @@ "FROM(" + "SELECT " + "CASE WHEN " + - "COUNT([ForeshoreProfileEntityId]) AND[ForeshoreProfileCollectionSourcePath] IS NULL " + + "COUNT([ForeshoreProfileEntityId]) AND [ForeshoreProfileCollectionSourcePath] IS NULL " + "OR " + "[ForeshoreProfileCollectionSourcePath] IS NOT NULL AND NOT COUNT([ForeshoreProfileEntityId]) " + "THEN 1 ELSE 0 END AS[IsInvalid] " + @@ -240,7 +240,7 @@ "FROM(" + "SELECT " + "CASE WHEN " + - "COUNT([ForeshoreProfileEntityId]) AND[ForeshoreProfileCollectionSourcePath] IS NULL " + + "COUNT([ForeshoreProfileEntityId]) AND [ForeshoreProfileCollectionSourcePath] IS NULL " + "OR " + "[ForeshoreProfileCollectionSourcePath] IS NOT NULL AND NOT COUNT([ForeshoreProfileEntityId]) " + "THEN 1 ELSE 0 END AS[IsInvalid] " +