Index: Ringtoets/Migration/src/Ringtoets.Migration.Core/EmbeddedResources/Migration_17.3_18.1.sql =================================================================== diff -u -r5d48e0aa51c523ad324f95fab597df31511ed06e -r0bf23391f0e54ec81094b93b84ae9b3ac511ecff --- Ringtoets/Migration/src/Ringtoets.Migration.Core/EmbeddedResources/Migration_17.3_18.1.sql (.../Migration_17.3_18.1.sql) (revision 5d48e0aa51c523ad324f95fab597df31511ed06e) +++ Ringtoets/Migration/src/Ringtoets.Migration.Core/EmbeddedResources/Migration_17.3_18.1.sql (.../Migration_17.3_18.1.sql) (revision 0bf23391f0e54ec81094b93b84ae9b3ac511ecff) @@ -10,8 +10,167 @@ INSERT INTO BackgroundDataEntity SELECT * FROM [SOURCEPROJECT].BackgroundDataEntity; INSERT INTO BackgroundDataMetaEntity SELECT * FROM [SOURCEPROJECT].BackgroundDataMetaEntity; INSERT INTO CalculationGroupEntity SELECT * FROM [SOURCEPROJECT].CalculationGroupEntity; -INSERT INTO ClosingStructureEntity SELECT * FROM [SOURCEPROJECT].ClosingStructureEntity; -INSERT INTO ClosingStructuresCalculationEntity SELECT * FROM [SOURCEPROJECT].ClosingStructuresCalculationEntity; +INSERT INTO ClosingStructureEntity ( + [ClosingStructureEntityId], + [FailureMechanismEntityId], + [Order], + [Name], + [Id], + [X], + [Y], + [StructureNormalOrientation], + [StorageStructureAreaMean], + [StorageStructureAreaCoefficientOfVariation], + [AllowedLevelIncreaseStorageMean], + [AllowedLevelIncreaseStorageStandardDeviation], + [WidthFlowAperturesMean], + [WidthFlowAperturesStandardDeviation], + [LevelCrestStructureNotClosingMean], + [LevelCrestStructureNotClosingStandardDeviation], + [InsideWaterLevelMean], + [InsideWaterLevelStandardDeviation], + [ThresholdHeightOpenWeirMean], + [ThresholdHeightOpenWeirStandardDeviation], + [AreaFlowAperturesMean], + [AreaFlowAperturesStandardDeviation], + [CriticalOvertoppingDischargeMean], + [CriticalOvertoppingDischargeCoefficientOfVariation], + [FlowWidthAtBottomProtectionMean], + [FlowWidthAtBottomProtectionStandardDeviation], + [ProbabilityOpenStructureBeforeFlooding], + [FailureProbabilityOpenStructure], + [IdenticalApertures], + [FailureProbabilityReparation], + [InflowModelType]) +SELECT + [ClosingStructureEntityId], + [FailureMechanismEntityId], + [Order], + [Name], + [Id], + [X], + [Y], + [StructureNormalOrientation], + [StorageStructureAreaMean], + [StorageStructureAreaCoefficientOfVariation], + [AllowedLevelIncreaseStorageMean], + [AllowedLevelIncreaseStorageStandardDeviation], + [WidthFlowAperturesMean], + [WidthFlowAperturesStandardDeviation], + [LevelCrestStructureNotClosingMean], + [LevelCrestStructureNotClosingStandardDeviation], + [InsideWaterLevelMean], + [InsideWaterLevelStandardDeviation], + [ThresholdHeightOpenWeirMean], + [ThresholdHeightOpenWeirStandardDeviation], + [AreaFlowAperturesMean], + [AreaFlowAperturesStandardDeviation], + [CriticalOvertoppingDischargeMean], + [CriticalOvertoppingDischargeCoefficientOfVariation], + [FlowWidthAtBottomProtectionMean], + [FlowWidthAtBottomProtectionStandardDeviation], + CASE + WHEN [ProbabilityOrFrequencyOpenStructureBeforeFlooding] > 1 + THEN NULL + ELSE + [ProbabilityOrFrequencyOpenStructureBeforeFlooding] + END, + [FailureProbabilityOpenStructure], + [IdenticalApertures], + [FailureProbabilityReparation], + [InflowModelType] +FROM [SOURCEPROJECT].ClosingStructureEntity; +INSERT INTO ClosingStructuresCalculationEntity ( + [ClosingStructuresCalculationEntityId], + [CalculationGroupEntityId], + [ForeshoreProfileEntityId], + [HydraulicLocationEntityId], + [ClosingStructureEntityId], + [Order], + [Name], + [Comments], + [UseBreakWater], + [BreakWaterType], + [BreakWaterHeight], + [UseForeshore], + [Orientation], + [StructureNormalOrientation], + [StorageStructureAreaMean], + [StorageStructureAreaCoefficientOfVariation], + [AllowedLevelIncreaseStorageMean], + [AllowedLevelIncreaseStorageStandardDeviation], + [WidthFlowAperturesMean], + [WidthFlowAperturesStandardDeviation], + [LevelCrestStructureNotClosingMean], + [LevelCrestStructureNotClosingStandardDeviation], + [InsideWaterLevelMean], + [InsideWaterLevelStandardDeviation], + [ThresholdHeightOpenWeirMean], + [ThresholdHeightOpenWeirStandardDeviation], + [AreaFlowAperturesMean], + [AreaFlowAperturesStandardDeviation], + [CriticalOvertoppingDischargeMean], + [CriticalOvertoppingDischargeCoefficientOfVariation], + [FlowWidthAtBottomProtectionMean], + [FlowWidthAtBottomProtectionStandardDeviation], + [ProbabilityOpenStructureBeforeFlooding], + [FailureProbabilityOpenStructure], + [IdenticalApertures], + [FailureProbabilityReparation], + [InflowModelType], + [FailureProbabilityStructureWithErosion], + [DeviationWaveDirection], + [DrainCoefficientMean], + [ModelFactorSuperCriticalFlowMean], + [StormDurationMean], + [FactorStormDurationOpenStructure], + [ShouldIllustrationPointsBeCalculated]) +SELECT + [ClosingStructuresCalculationEntityId], + [CalculationGroupEntityId], + [ForeshoreProfileEntityId], + [HydraulicLocationEntityId], + [ClosingStructureEntityId], + [Order], + [Name], + [Comments], + [UseBreakWater], + [BreakWaterType], + [BreakWaterHeight], + [UseForeshore], + [Orientation], + [StructureNormalOrientation], + [StorageStructureAreaMean], + [StorageStructureAreaCoefficientOfVariation], + [AllowedLevelIncreaseStorageMean], + [AllowedLevelIncreaseStorageStandardDeviation], + [WidthFlowAperturesMean], + [WidthFlowAperturesStandardDeviation], + [LevelCrestStructureNotClosingMean], + [LevelCrestStructureNotClosingStandardDeviation], + [InsideWaterLevelMean], + [InsideWaterLevelStandardDeviation], + [ThresholdHeightOpenWeirMean], + [ThresholdHeightOpenWeirStandardDeviation], + [AreaFlowAperturesMean], + [AreaFlowAperturesStandardDeviation], + [CriticalOvertoppingDischargeMean], + [CriticalOvertoppingDischargeCoefficientOfVariation], + [FlowWidthAtBottomProtectionMean], + [FlowWidthAtBottomProtectionStandardDeviation], + [ProbabilityOrFrequencyOpenStructureBeforeFlooding], + [FailureProbabilityOpenStructure], + [IdenticalApertures], + [FailureProbabilityReparation], + [InflowModelType], + [FailureProbabilityStructureWithErosion], + [DeviationWaveDirection], + [DrainCoefficientMean], + [ModelFactorSuperCriticalFlowMean], + [StormDurationMean], + [FactorStormDurationOpenStructure], + [ShouldIllustrationPointsBeCalculated] + FROM [SOURCEPROJECT].ClosingStructuresCalculationEntity; INSERT INTO ClosingStructuresFailureMechanismMetaEntity SELECT * FROM [SOURCEPROJECT].ClosingStructuresFailureMechanismMetaEntity; INSERT INTO ClosingStructuresOutputEntity( [ClosingStructuresOutputEntityId], Index: Ringtoets/Migration/test/Ringtoets.Migration.Core.Test/test-data/MigrationTestProject173.rtd =================================================================== diff -u -r76b58930181c2ae98cb4c040ff9767f4a790e006 -r0bf23391f0e54ec81094b93b84ae9b3ac511ecff Binary files differ Index: Ringtoets/Migration/test/Ringtoets.Migration.Core.Test/test-data/MigrationTestProject181.rtd =================================================================== diff -u -r5d48e0aa51c523ad324f95fab597df31511ed06e -r0bf23391f0e54ec81094b93b84ae9b3ac511ecff Binary files differ Index: Ringtoets/Migration/test/Ringtoets.Migration.Integration.Test/MigrationTo181IntegrationTest.cs =================================================================== diff -u -r5d48e0aa51c523ad324f95fab597df31511ed06e -r0bf23391f0e54ec81094b93b84ae9b3ac511ecff --- Ringtoets/Migration/test/Ringtoets.Migration.Integration.Test/MigrationTo181IntegrationTest.cs (.../MigrationTo181IntegrationTest.cs) (revision 5d48e0aa51c523ad324f95fab597df31511ed06e) +++ Ringtoets/Migration/test/Ringtoets.Migration.Integration.Test/MigrationTo181IntegrationTest.cs (.../MigrationTo181IntegrationTest.cs) (revision 0bf23391f0e54ec81094b93b84ae9b3ac511ecff) @@ -129,12 +129,72 @@ MigratedSerializedDataTestHelper.AssertSerializedDikeProfileRoughnessPoints(reader); MigratedSerializedDataTestHelper.AssertSerializedSurfaceLine(reader); MigratedSerializedDataTestHelper.AssertSerializedPoint2DCollection(reader); + + AssertClosingStructure(reader, sourceFilePath); } AssertLogDatabase(logFilePath); } } + private static void AssertClosingStructure(MigratedDatabaseReader reader, string sourceFilePath) + { + string validateClosingStructureProbabilityOpenStructureBeforeFlooding = + $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT " + + "SUM([IsInvalid]) = 0 " + + "FROM " + + "( " + + "SELECT " + + "CASE WHEN (NEW.[ProbabilityOpenStructureBeforeFlooding] IS NOT OLD.[ProbabilityOrFrequencyOpenStructureBeforeFlooding] " + + "AND OLD.[ProbabilityOrFrequencyOpenStructureBeforeFlooding] <= 1) " + + "OR (NEW.[ProbabilityOpenStructureBeforeFlooding] IS NOT NULL AND OLD.[ProbabilityOrFrequencyOpenStructureBeforeFlooding] > 1) " + + "THEN 1 " + + "ELSE 0 " + + "END AS [IsInvalid] " + + "FROM ClosingStructureEntity NEW " + + "JOIN [SOURCEPROJECT].ClosingStructureEntity OLD USING (ClosingStructureEntityId) " + + "); " + + "DETACH DATABASE SOURCEPROJECT;"; + reader.AssertReturnedDataIsValid(validateClosingStructureProbabilityOpenStructureBeforeFlooding); + + string validateClosingStructure = + $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT COUNT() = (SELECT COUNT() FROM [SOURCEPROJECT].ClosingStructureEntity) " + + "FROM ClosingStructureEntity NEW " + + "JOIN [SOURCEPROJECT].ClosingStructureEntity OLD USING(ClosingStructureEntityId) " + + "WHERE NEW.FailureMechanismEntityId = OLD.FailureMechanismEntityId " + + "AND NEW.\"Order\" = OLD.\"Order\"; " + + "AND NEW.Name = OLD.Name " + + "AND NEW.X IS OLD.X " + + "AND NEW.Y IS OLD.Y" + + "AND NEW.StructureNormalOrientation IS OLD.StructureNormalOrientation" + + "AND NEW.StorageStructureAreaMean IS OLD.StorageStructureAreaMean" + + "AND NEW.StorageStructureAreaCoefficientOfVariation IS OLD.StorageStructureAreaCoefficientOfVariation" + + "AND NEW.AllowedLevelIncreaseStorageMean IS OLD.AllowedLevelIncreaseStorageMean" + + "AND NEW.AllowedLevelIncreaseStorageStandardDeviation IS OLD.AllowedLevelIncreaseStorageStandardDeviation" + + "AND NEW.WidthFlowAperturesMean IS OLD.WidthFlowAperturesMean" + + "AND NEW.WidthFlowAperturesStandardDeviation IS OLD.WidthFlowAperturesStandardDeviation" + + "AND NEW.LevelCrestStructureNotClosingMean IS OLD.LevelCrestStructureNotClosingMean" + + "AND NEW.LevelCrestStructureNotClosingStandardDeviation IS OLD.LevelCrestStructureNotClosingStandardDeviation" + + "AND NEW.InsideWaterLevelMean IS OLD.InsideWaterLevelMean" + + "AND NEW.InsideWaterLevelStandardDeviation IS OLD.InsideWaterLevelStandardDeviation" + + "AND NEW.ThresholdHeightOpenWeirMean IS OLD.ThresholdHeightOpenWeirMean" + + "AND NEW.ThresholdHeightOpenWeirStandardDeviation IS OLD.ThresholdHeightOpenWeirStandardDeviation" + + "AND NEW.AreaFlowAperturesMean IS OLD.AreaFlowAperturesMean" + + "AND NEW.AreaFlowAperturesStandardDeviation IS OLD.AreaFlowAperturesStandardDeviation" + + "AND NEW.CriticalOvertoppingDischargeMean IS OLD.CriticalOvertoppingDischargeMean" + + "AND NEW.CriticalOvertoppingDischargeCoefficientOfVariation IS OLD.CriticalOvertoppingDischargeCoefficientOfVariation" + + "AND NEW.FlowWidthAtBottomProtectionMean IS OLD.FlowWidthAtBottomProtectionMean" + + "AND NEW.FlowWidthAtBottomProtectionStandardDeviation IS OLD.FlowWidthAtBottomProtectionStandardDeviation" + + "AND NEW.FailureProbabilityOpenStructure IS OLD.FailureProbabilityOpenStructure" + + "AND NEW.IdenticalApertures IS OLD.IdenticalApertures" + + "AND NEW.FailureProbabilityReparation IS OLD.FailureProbabilityReparation" + + "AND NEW.InflowModelType IS OLD.InflowModelType;" + + "DETACH DATABASE SOURCEPROJECT;"; + reader.AssertReturnedDataIsValid(validateClosingStructure); + } + private static void AssertTablesContentMigrated(MigratedDatabaseReader reader, string sourceFilePath) { string[] tables =