Index: Core/Common/src/Core.Common.Utils/FileUtils.cs =================================================================== diff -u -r589249bddd12bd66da39205d408ff6e907220116 -r6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b --- Core/Common/src/Core.Common.Utils/FileUtils.cs (.../FileUtils.cs) (revision 589249bddd12bd66da39205d408ff6e907220116) +++ Core/Common/src/Core.Common.Utils/FileUtils.cs (.../FileUtils.cs) (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -138,5 +138,26 @@ throw; } } + + public static void ValidateFilePathIsWritable(string filePath) + { + ValidateFilePath(filePath); + + var canWrite = false; + try + { + using (var fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write)) + { + canWrite = fs.CanWrite; + } + } + finally + { + if (!canWrite) + { + throw new ArgumentException(string.Format(Resources.Error_General_output_error_0, filePath)); + } + } + } } } \ No newline at end of file Index: Core/Common/test/Core.Common.TestUtil/TestDataPath.cs =================================================================== diff -u -r1e3de334f82be7cffe88d7e80dc336fcdec81086 -r6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b --- Core/Common/test/Core.Common.TestUtil/TestDataPath.cs (.../TestDataPath.cs) (revision 1e3de334f82be7cffe88d7e80dc336fcdec81086) +++ Core/Common/test/Core.Common.TestUtil/TestDataPath.cs (.../TestDataPath.cs) (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -62,6 +62,14 @@ } } + public static class Migration + { + public static class Core + { + public static readonly TestDataPath Storage = System.IO.Path.Combine("Migration", "Core", "test", "Migration.Core.Storage.Test"); + } + } + public static class Ringtoets { public static class ClosingStructures Index: Core/Common/test/Core.Common.Utils.Test/FileUtilsTest.cs =================================================================== diff -u -r2aa9661130f20e88c41dac921ffb780573dcf799 -r6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b --- Core/Common/test/Core.Common.Utils.Test/FileUtilsTest.cs (.../FileUtilsTest.cs) (revision 2aa9661130f20e88c41dac921ffb780573dcf799) +++ Core/Common/test/Core.Common.Utils.Test/FileUtilsTest.cs (.../FileUtilsTest.cs) (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -214,5 +214,59 @@ Assert.IsFalse(File.Exists(filePath)); } } + + [Test] + [TestCase("")] + [TestCase(" ")] + [TestCase(null)] + public void ValidateFilePathIsWritable_FilePatNullOrWhiteSpace_ThrowsArgumentException(string filePath) + { + // Call + TestDelegate call = () => FileUtils.ValidateFilePathIsWritable(filePath); + + // Assert + ArgumentException exception = Assert.Throws(call); + Assert.AreEqual($"Fout bij het lezen van bestand '{filePath}': bestandspad mag niet leeg of ongedefinieerd zijn.", exception.Message); + } + + [Test] + public void ValidateFilePathIsWritable_FileNotWritable_ThrowsArgumentException() + { + // Setup + string filename = Path.GetRandomFileName(); + string filePath = TestHelper.GetTestDataPath(TestDataPath.Core.Common.Utils, filename); + + using (new FileDisposeHelper(filePath)) + { + FileAttributes attributes = File.GetAttributes(filePath); + File.SetAttributes(filePath, attributes | FileAttributes.ReadOnly); + + // Call + TestDelegate call = () => FileUtils.ValidateFilePathIsWritable(filePath); + + // Assert + string message = Assert.Throws(call).Message; + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.", message); + + File.SetAttributes(filePath, attributes); + } + } + + [Test] + public void ValidateFilePathIsWritable_FileWritable_DoesNotThrowException() + { + // Setup + string filename = Path.GetRandomFileName(); + string filePath = TestHelper.GetTestDataPath(TestDataPath.Core.Common.Utils, filename); + + using (new FileDisposeHelper(filePath)) + { + // Call + TestDelegate call = () => FileUtils.ValidateFilePathIsWritable(filePath); + + // Assert + Assert.DoesNotThrow(call); + } + } } } \ No newline at end of file Index: Migration/Console/test/Migration.Console.Test/Migration.Console.Test.csproj =================================================================== diff -u -r535a93fde55619f58673f758edae5dc7c1b9df51 -r6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b --- Migration/Console/test/Migration.Console.Test/Migration.Console.Test.csproj (.../Migration.Console.Test.csproj) (revision 535a93fde55619f58673f758edae5dc7c1b9df51) +++ Migration/Console/test/Migration.Console.Test/Migration.Console.Test.csproj (.../Migration.Console.Test.csproj) (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -1,6 +1,5 @@  - Debug x86 Index: Migration/Core/src/Migration.Core.Storage/Exceptions/CriticalDatabaseMigrationException.cs =================================================================== diff -u --- Migration/Core/src/Migration.Core.Storage/Exceptions/CriticalDatabaseMigrationException.cs (revision 0) +++ Migration/Core/src/Migration.Core.Storage/Exceptions/CriticalDatabaseMigrationException.cs (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -0,0 +1,38 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Runtime.Serialization; + +namespace Migration.Core.Storage.Exceptions +{ + [Serializable] + public class CriticalDatabaseMigrationException : Exception + { + public CriticalDatabaseMigrationException() { } + + public CriticalDatabaseMigrationException(string message) : base(message) { } + + public CriticalDatabaseMigrationException(string message, Exception inner) : base(message, inner) { } + + protected CriticalDatabaseMigrationException(SerializationInfo info, StreamingContext context) : base(info, context) { } + } +} \ No newline at end of file Index: Migration/Core/src/Migration.Core.Storage/Migration.Core.Storage.csproj =================================================================== diff -u -r535a93fde55619f58673f758edae5dc7c1b9df51 -r6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b --- Migration/Core/src/Migration.Core.Storage/Migration.Core.Storage.csproj (.../Migration.Core.Storage.csproj) (revision 535a93fde55619f58673f758edae5dc7c1b9df51) +++ Migration/Core/src/Migration.Core.Storage/Migration.Core.Storage.csproj (.../Migration.Core.Storage.csproj) (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -50,16 +50,17 @@ Properties\GlobalAssembly.cs + True True Resources.resx - + - + @@ -74,10 +75,28 @@ - + DbContext\DatabaseStructure + + + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} + Core.Common.Base + + + {e344867e-9ac9-44c8-88a5-8185681679a9} + Core.Common.IO + + + {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} + Core.Common.Utils + + + {d08db9e2-6861-44c8-a725-71a70274cc77} + Migration.Scripts.Data + + Index: Migration/Core/src/Migration.Core.Storage/MigrationDatabaseSourceFile.cs =================================================================== diff -u --- Migration/Core/src/Migration.Core.Storage/MigrationDatabaseSourceFile.cs (revision 0) +++ Migration/Core/src/Migration.Core.Storage/MigrationDatabaseSourceFile.cs (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -0,0 +1,75 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Data; +using Core.Common.Base.Storage; +using Core.Common.IO.Exceptions; +using Core.Common.IO.Readers; +using Migration.Scripts.Data; + +namespace Migration.Core.Storage +{ + /// + /// Class that provides methods for the migration database source file. + /// + public class MigrationDatabaseSourceFile : SqLiteDatabaseReaderBase + { + /// + /// Creates a new instance of the class. + /// + /// The path to the source file. + /// Thrown when: + /// + /// The contains invalid characters. + /// No file could be found at . + /// Unable to open database file. + /// + /// + public MigrationDatabaseSourceFile(string databaseFilePath) : base(databaseFilePath) {} + + /// + /// Gets the current version. + /// + /// The version. + /// Thrown when is not a valid file. + public string GetVersion() + { + string versionQuery = RingtoetsDatabaseQueryBuilder.GetVersionQuery(); + try + { + using (IDataReader dataReader = CreateDataReader(versionQuery, null)) + { + if (!dataReader.Read()) + { + return string.Empty; + } + + return dataReader.Read(VersionTableDefinitions.Version); + } + } + catch (SystemException exception) + { + throw new StorageValidationException("$Het bestand '{FilePath}' is geen geldig Ringtoets database bestand.", exception); + } + } + } +} \ No newline at end of file Index: Migration/Core/src/Migration.Core.Storage/MigrationDatabaseTargetFile.cs =================================================================== diff -u --- Migration/Core/src/Migration.Core.Storage/MigrationDatabaseTargetFile.cs (revision 0) +++ Migration/Core/src/Migration.Core.Storage/MigrationDatabaseTargetFile.cs (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -0,0 +1,125 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Data.SQLite; +using Core.Common.Utils; + +namespace Migration.Core.Storage +{ + /// + /// Class that provides methods for the migration database target file. + /// + public class MigrationDatabaseTargetFile : IDisposable + { + private SQLiteConnection connection; + private bool disposed; + + /// + /// Creates a new instance of the class. + /// + /// The path to the target file. + /// Thrown when : + /// + /// is not empty or null, + /// does not consist out of only whitespace characters, + /// does not contain an invalid character, + /// does not end with a directory or path separator (empty file name), + /// is not writable. + /// + public MigrationDatabaseTargetFile(string filePath) + { + FileUtils.ValidateFilePathIsWritable(filePath); + + FilePath = filePath; + } + + /// + /// Opens the connection to the file. + /// + /// Creates the file if it does not exist. + public void OpenDatabaseConnection() + { + SQLiteConnection.CreateFile(FilePath); + connection = new SQLiteConnection(SqLiteConnectionStringBuilder.BuildSqLiteConnectionString(FilePath, false)); + connection.Open(); + } + + /// + /// Executes the that will create the database structure. + /// + /// Create structure query to execute. + /// Thrown when is null + /// or consist out of only whitespace characters. + /// Thrown when executing failed. + public void CreateStructure(string query) + { + PerformExecuteQuery(query); + } + + /// + /// Executes the that will migrate the data. + /// + /// Migration query to execute. + /// Thrown when is null + /// or consist out of only whitespace characters. + /// Thrown when executing failed. + public void ExecuteMigration(string query) + { + PerformExecuteQuery(query); + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private string FilePath { get; } + + private void PerformExecuteQuery(string query) + { + if (string.IsNullOrWhiteSpace(query)) + { + throw new ArgumentException(@"Parameter must be a valid database script.", nameof(query)); + } + using (var command = connection.CreateCommand()) + { + command.CommandText = query; + command.ExecuteNonQuery(); + } + } + + private void Dispose(bool disposing) + { + if (disposed) + { + return; + } + + if (disposing) + { + connection?.Dispose(); + } + disposed = true; + } + } +} \ No newline at end of file Index: Migration/Core/src/Migration.Core.Storage/MigrationService.cs =================================================================== diff -u -r535a93fde55619f58673f758edae5dc7c1b9df51 -r6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b --- Migration/Core/src/Migration.Core.Storage/MigrationService.cs (.../MigrationService.cs) (revision 535a93fde55619f58673f758edae5dc7c1b9df51) +++ Migration/Core/src/Migration.Core.Storage/MigrationService.cs (.../MigrationService.cs) (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -19,27 +19,64 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using ScriptsDataPropertiesResources = Migration.Scripts.Data.Properties.Resources; + namespace Migration.Core.Storage { + /// + /// Class responsible for performing migrations. + /// public static class MigrationService { + /// + /// Executes the migration from to . + /// + /// The source file that needs to be migrated. + /// The target file that will contain the migrated data from . + /// Thrown when: + /// + /// is the same file as . + /// public static void Execute(string sourceFile, string targetFile) { - using (var source = new SourceFile(sourceFile)) - using (var target = new TargetFile(targetFile)) + if (sourceFile == targetFile) { + throw new ArgumentException($"{sourceFile} cannot be the same location as {targetFile}"); + } + + using (var source = new MigrationDatabaseSourceFile(sourceFile)) + using (var target = new MigrationDatabaseTargetFile(targetFile)) + { target.OpenDatabaseConnection(); - target.CreateStructure(); - Migrate(source, target); + + string version = source.GetVersion(); + switch (version) + { + case "4": + MigrateVersion4To171(source, target); + break; + case "17.1": + // throw exception? + break; + default: + throw new InvalidOperationException($"Version {version} cannot be upgraded."); + } } } - private static void Migrate(SourceFile source, TargetFile target) + private static void MigrateVersion4To171(MigrationDatabaseSourceFile source, MigrationDatabaseTargetFile target) { -// var script = MigrationScriptTable.Get(""); -// var sourceFilePath = source.FilePath; -// var sql = string.Format(script, sourceFilePath); -// target.Execute(sql); + target.CreateStructure(ScriptsDataPropertiesResources.DatabaseStructure17_1); + + var query = GetMigrationQuery(ScriptsDataPropertiesResources.Migration4_17_1, source.Path); + + target.ExecuteMigration(query); } + + private static string GetMigrationQuery(string migrationScript, string sourceFilePath) + { + return string.Format(migrationScript, sourceFilePath); + } } } \ No newline at end of file Fisheye: Tag 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b refers to a dead (removed) revision in file `Migration/Core/src/Migration.Core.Storage/SourceFile.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b refers to a dead (removed) revision in file `Migration/Core/src/Migration.Core.Storage/TargetFile.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Migration/Core/test/Migration.Core.Storage.Test/Migration.Core.Storage.Test.csproj =================================================================== diff -u -r535a93fde55619f58673f758edae5dc7c1b9df51 -r6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b --- Migration/Core/test/Migration.Core.Storage.Test/Migration.Core.Storage.Test.csproj (.../Migration.Core.Storage.Test.csproj) (revision 535a93fde55619f58673f758edae5dc7c1b9df51) +++ Migration/Core/test/Migration.Core.Storage.Test/Migration.Core.Storage.Test.csproj (.../Migration.Core.Storage.Test.csproj) (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -1,8 +1,7 @@  - - Debug + Debug x86 {01776D8B-4BAC-444C-B566-5E398088BDFC} Library @@ -62,14 +61,31 @@ Properties\GlobalAssembly.cs + + + Copying.licenseheader + + + {e344867e-9ac9-44c8-88a5-8185681679a9} + Core.Common.IO + + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + + + {EFD7E662-5B69-4B71-A448-565B64E9C033} + Migration.Core.Storage + + Index: Migration/Core/test/Migration.Core.Storage.Test/MigrationDatabaseSourceFileTest.cs =================================================================== diff -u --- Migration/Core/test/Migration.Core.Storage.Test/MigrationDatabaseSourceFileTest.cs (revision 0) +++ Migration/Core/test/Migration.Core.Storage.Test/MigrationDatabaseSourceFileTest.cs (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -0,0 +1,67 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.IO; +using Core.Common.IO.Readers; +using Core.Common.TestUtil; +using NUnit.Framework; + +namespace Migration.Core.Storage.Test +{ + [TestFixture] + public class MigrationDatabaseSourceFileTest + { + [Test] + public void SourceFile_ParameteredConstructor_ExptectedProperties() + { + // Setup + string targetFilename = Path.GetRandomFileName(); + string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, targetFilename); + + using (new FileDisposeHelper(filePath)) + { + // Call + using (var sourceFile = new MigrationDatabaseSourceFile(filePath)) + { + // Assert + Assert.IsInstanceOf(sourceFile); + Assert.AreEqual(filePath, sourceFile.Path); + } + } + } + + [Test] + [TestCase("Demo164.rtd", "4")] + [TestCase("Demo171.rtd", "17.1")] + public void GetVersion_ParameteredConstructor_ExptectedProperties(string file, string expectedVersion) + { + // Setup + string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, file); + + // Call + using (var sourceFile = new MigrationDatabaseSourceFile(filePath)) + { + // Assert + Assert.AreEqual(expectedVersion, sourceFile.GetVersion()); + } + } + } +} \ No newline at end of file Index: Migration/Core/test/Migration.Core.Storage.Test/MigrationDatabaseTargetFileTest.cs =================================================================== diff -u --- Migration/Core/test/Migration.Core.Storage.Test/MigrationDatabaseTargetFileTest.cs (revision 0) +++ Migration/Core/test/Migration.Core.Storage.Test/MigrationDatabaseTargetFileTest.cs (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -0,0 +1,75 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.IO; +using Core.Common.TestUtil; +using NUnit.Framework; + +namespace Migration.Core.Storage.Test +{ + [TestFixture] + public class MigrationDatabaseTargetFileTest + { + [Test] + [TestCase("")] + [TestCase(" ")] + [TestCase(null)] + public void Constructor_InvalidPath_ThrowsArgumentException(string filePath) + { + // Call + TestDelegate call = () => + { + using (new MigrationDatabaseTargetFile(filePath)) {} + }; + + // Assert + string message = Assert.Throws(call).Message; + Assert.AreEqual($"Fout bij het lezen van bestand '{filePath}': bestandspad mag niet leeg of ongedefinieerd zijn.", message); + } + + [Test] + public void Constructor_FileExistsButNotWritable_ThrowsArgumentException() + { + // Setup + string filename = Path.GetRandomFileName(); + string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, filename); + + using (new FileDisposeHelper(filePath)) + { + FileAttributes attributes = File.GetAttributes(filePath); + File.SetAttributes(filePath, attributes | FileAttributes.ReadOnly); + + // Call + TestDelegate call = () => + { + using (new MigrationDatabaseTargetFile(filePath)) {} + }; + + // Assert + string message = Assert.Throws(call).Message; + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.", message); + + File.SetAttributes(filePath, attributes); + } + } + } +} \ No newline at end of file Index: Migration/Core/test/Migration.Core.Storage.Test/MigrationServiceTest.cs =================================================================== diff -u --- Migration/Core/test/Migration.Core.Storage.Test/MigrationServiceTest.cs (revision 0) +++ Migration/Core/test/Migration.Core.Storage.Test/MigrationServiceTest.cs (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -0,0 +1,72 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.IO; +using Core.Common.TestUtil; +using NUnit.Framework; + +namespace Migration.Core.Storage.Test +{ + [TestFixture] + public class MigrationServiceTest + { + [Test] + public void Execute_SourceAndTargetLocationAreEqual_ThrowsArgumentExeption() + { + // Setup + const string samePath = "c:\\someValidPath"; + + // Call + TestDelegate call = () => MigrationService.Execute(samePath, samePath); + + // Assert + string message = Assert.Throws(call).Message; + Assert.AreEqual($"{samePath} cannot be the same location as {samePath}", message); + } + + [Test] + public void Execute_Migrate4To171_MigratesToNewFile() + { + // Setup + string targetFilename = Path.GetRandomFileName(); + string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, "Demo164.rtd"); + string targetFilePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, targetFilename); + + using (new FileDisposeHelper(targetFilePath)) + { + // Call + MigrationService.Execute(sourceFilePath, targetFilePath); + + // Assert + ValidateFileVersion(targetFilePath, "17.1"); + } + } + + private static void ValidateFileVersion(string filePath, string expectedVersion) + { + using (var source = new MigrationDatabaseSourceFile(filePath)) + { + Assert.AreEqual(expectedVersion, source.GetVersion()); + } + } + } +} \ No newline at end of file Index: Migration/Core/test/Migration.Core.Storage.Test/test-data/Demo164.rtd =================================================================== diff -u Binary files differ Index: Migration/Core/test/Migration.Core.Storage.Test/test-data/Demo171.rtd =================================================================== diff -u Binary files differ Index: Migration/Scripts/src/Migration.Scripts.Data/Migration.Scripts.Data.csproj =================================================================== diff -u -r535a93fde55619f58673f758edae5dc7c1b9df51 -r6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b --- Migration/Scripts/src/Migration.Scripts.Data/Migration.Scripts.Data.csproj (.../Migration.Scripts.Data.csproj) (revision 535a93fde55619f58673f758edae5dc7c1b9df51) +++ Migration/Scripts/src/Migration.Scripts.Data/Migration.Scripts.Data.csproj (.../Migration.Scripts.Data.csproj) (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -40,12 +40,32 @@ Properties\GlobalAssembly.cs + + True + True + Resources.resx + + + Copying.licenseheader + + + PublicResXFileCodeGenerator + Resources.Designer.cs + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\DatabaseStructure17.1.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + + ..\Resources\Migration_4_17.1.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + \ No newline at end of file Index: Migration/Scripts/src/Migration.Scripts.Data/Resources/DatabaseStructure17.1.sql =================================================================== diff -u --- Migration/Scripts/src/Migration.Scripts.Data/Resources/DatabaseStructure17.1.sql (revision 0) +++ Migration/Scripts/src/Migration.Scripts.Data/Resources/DatabaseStructure17.1.sql (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -0,0 +1,1683 @@ +/* ---------------------------------------------------- */ +/* Generated by Enterprise Architect Version 12.0 */ +/* Created On : 12-Jan-2017 2:31:23 PM */ +/* DBMS : SQLite */ +/* ---------------------------------------------------- */ + +/* Drop Tables */ + +DROP TABLE IF EXISTS 'VersionEntity' +; + +DROP TABLE IF EXISTS 'GrassCoverErosionInwardsDikeHeightOutputEntity' +; + +DROP TABLE IF EXISTS 'ProjectEntity' +; + +DROP TABLE IF EXISTS 'StabilityPointStructuresCalculationEntity' +; + +DROP TABLE IF EXISTS 'AssessmentSectionEntity' +; + +DROP TABLE IF EXISTS 'FailureMechanismEntity' +; + +DROP TABLE IF EXISTS 'FailureMechanismSectionEntity' +; + +DROP TABLE IF EXISTS 'PipingFailureMechanismMetaEntity' +; + +DROP TABLE IF EXISTS 'StabilityPointStructuresFailureMechanismMetaEntity' +; + +DROP TABLE IF EXISTS 'ClosingStructuresFailureMechanismMetaEntity' +; + +DROP TABLE IF EXISTS 'DuneErosionFailureMechanismMetaEntity' +; + +DROP TABLE IF EXISTS 'CalculationGroupEntity' +; + +DROP TABLE IF EXISTS 'HeightStructuresFailureMechanismMetaEntity' +; + +DROP TABLE IF EXISTS 'HydraulicLocationEntity' +; + +DROP TABLE IF EXISTS 'PipingCalculationEntity' +; + +DROP TABLE IF EXISTS 'GrassCoverErosionInwardsFailureMechanismMetaEntity' +; + +DROP TABLE IF EXISTS 'GrassCoverErosionInwardsCalculationEntity' +; + +DROP TABLE IF EXISTS 'GrassCoverErosionOutwardsFailureMechanismMetaEntity' +; + +DROP TABLE IF EXISTS 'SoilLayerEntity' +; + +DROP TABLE IF EXISTS 'SoilProfileEntity' +; + +DROP TABLE IF EXISTS 'StochasticSoilProfileEntity' +; + +DROP TABLE IF EXISTS 'StochasticSoilModelEntity' +; + +DROP TABLE IF EXISTS 'SurfaceLineEntity' +; + +DROP TABLE IF EXISTS 'CharacteristicPointEntity' +; + +DROP TABLE IF EXISTS 'PipingCalculationOutputEntity' +; + +DROP TABLE IF EXISTS 'PipingSemiProbabilisticOutputEntity' +; + +DROP TABLE IF EXISTS 'PipingSectionResultEntity' +; + +DROP TABLE IF EXISTS 'GrassCoverErosionInwardsSectionResultEntity' +; + +DROP TABLE IF EXISTS 'HeightStructuresSectionResultEntity' +; + +DROP TABLE IF EXISTS 'StrengthStabilityLengthwiseConstructionSectionResultEntity' +; + +DROP TABLE IF EXISTS 'TechnicalInnovationSectionResultEntity' +; + +DROP TABLE IF EXISTS 'WaterPressureAsphaltCoverSectionResultEntity' +; + +DROP TABLE IF EXISTS 'ClosingStructuresSectionResultEntity' +; + +DROP TABLE IF EXISTS 'GrassCoverErosionOutwardsSectionResultEntity' +; + +DROP TABLE IF EXISTS 'GrassCoverSlipOffInwardsSectionResultEntity' +; + +DROP TABLE IF EXISTS 'GrassCoverSlipOffOutwardsSectionResultEntity' +; + +DROP TABLE IF EXISTS 'MacrostabilityInwardsSectionResultEntity' +; + +DROP TABLE IF EXISTS 'MacrostabilityOutwardsSectionResultEntity' +; + +DROP TABLE IF EXISTS 'WaveImpactAsphaltCoverSectionResultEntity' +; + +DROP TABLE IF EXISTS 'MicrostabilitySectionResultEntity' +; + +DROP TABLE IF EXISTS 'PipingStructureSectionResultEntity' +; + +DROP TABLE IF EXISTS 'DuneErosionSectionResultEntity' +; + +DROP TABLE IF EXISTS 'StabilityStoneCoverSectionResultEntity' +; + +DROP TABLE IF EXISTS 'StabilityPointStructuresSectionResultEntity' +; + +DROP TABLE IF EXISTS 'DikeProfileEntity' +; + +DROP TABLE IF EXISTS 'GrassCoverErosionInwardsOutputEntity' +; + +DROP TABLE IF EXISTS 'ForeshoreProfileEntity' +; + +DROP TABLE IF EXISTS 'StabilityStoneCoverWaveConditionsCalculationEntity' +; + +DROP TABLE IF EXISTS 'StabilityStoneCoverWaveConditionsOutputEntity' +; + +DROP TABLE IF EXISTS 'WaveImpactAsphaltCoverWaveConditionsCalculationEntity' +; + +DROP TABLE IF EXISTS 'WaveImpactAsphaltCoverWaveConditionsOutputEntity' +; + +DROP TABLE IF EXISTS 'GrassCoverErosionOutwardsWaveConditionsCalculationEntity' +; + +DROP TABLE IF EXISTS 'GrassCoverErosionOutwardsHydraulicLocationEntity' +; + +DROP TABLE IF EXISTS 'GrassCoverErosionOutwardsWaveConditionsOutputEntity' +; + +DROP TABLE IF EXISTS 'HeightStructuresOutputEntity' +; + +DROP TABLE IF EXISTS 'HeightStructureEntity' +; + +DROP TABLE IF EXISTS 'HeightStructuresCalculationEntity' +; + +DROP TABLE IF EXISTS 'ClosingStructureEntity' +; + +DROP TABLE IF EXISTS 'ClosingStructuresCalculationEntity' +; + +DROP TABLE IF EXISTS 'ClosingStructuresOutputEntity' +; + +DROP TABLE IF EXISTS 'StabilityPointStructureEntity' +; + +DROP TABLE IF EXISTS 'StabilityPointStructuresOutputEntity' +; + +DROP TABLE IF EXISTS 'HydraulicLocationOutputEntity' +; + +DROP TABLE IF EXISTS 'GrassCoverErosionOutwardsHydraulicLocationOutputEntity' +; + +DROP TABLE IF EXISTS 'DuneLocationEntity' +; + +DROP TABLE IF EXISTS 'DuneLocationOutputEntity' +; + +/* Create Tables with Primary and Foreign Keys, Check and Unique Constraints */ + +CREATE TABLE 'VersionEntity' +( + 'VersionId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'Version' VARCHAR (20) NOT NULL, + 'Timestamp' DATETIME NOT NULL, + 'FingerPrint' BLOB NOT NULL +) +; + +CREATE TABLE 'GrassCoverErosionInwardsDikeHeightOutputEntity' +( + 'GrassCoverErosionInwardsDikeHeightOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'GrassCoverErosionInwardsOutputEntityId' INTEGER NOT NULL, + 'DikeHeight' REAL, + 'TargetProbability' REAL, + 'TargetReliability' REAL, + 'CalculatedProbability' REAL, + 'CalculatedReliability' REAL, + 'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculationNotConverged, 3 = CalculationConverged + CONSTRAINT 'FK_GrassCoverErosionInwardsDikeHeightOutputEntity_GrassCoverErosionInwardsOutputEntity' FOREIGN KEY ('GrassCoverErosionInwardsOutputEntityId') REFERENCES 'GrassCoverErosionInwardsOutputEntity' ('GrassCoverErosionInwardsOutputEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'U_GrassCoverErosionInwardsOutputEntity' UNIQUE ('GrassCoverErosionInwardsOutputEntityId') +) +; + +CREATE TABLE 'ProjectEntity' +( + 'ProjectEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'Description' VARCHAR (260) +) +; + +CREATE TABLE 'StabilityPointStructuresCalculationEntity' +( + 'StabilityPointStructuresCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'CalculationGroupEntityId' INTEGER NOT NULL, + 'ForeshoreProfileEntityId' INTEGER, + 'HydraulicLocationEntityId' INTEGER, + 'StabilityPointStructureEntityId' INTEGER, + 'Order' INT (4) NOT NULL, + 'Name' VARCHAR (260), + 'Comments' TEXT, + 'UseBreakWater' TINYINT (1) NOT NULL, -- true or false + 'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam + 'BreakWaterHeight' REAL, + 'UseForeshore' TINYINT (1) NOT NULL, -- true or false + 'StructureNormalOrientation' REAL, + 'StorageStructureAreaMean' REAL, + 'StorageStructureAreaCoefficientOfVariation' REAL, + 'AllowedLevelIncreaseStorageMean' REAL, + 'AllowedLevelIncreaseStorageStandardDeviation' REAL, + 'WidthFlowAperturesMean' REAL, + 'WidthFlowAperturesStandardDeviation' REAL, + 'InsideWaterLevelMean' REAL, + 'InsideWaterLevelStandardDeviation' REAL, + 'ThresholdHeightOpenWeirMean' REAL, + 'ThresholdHeightOpenWeirStandardDeviation' REAL, + 'CriticalOvertoppingDischargeMean' REAL, + 'CriticalOvertoppingDischargeCoefficientOfVariation' REAL, + 'FlowWidthAtBottomProtectionMean' REAL, + 'FlowWidthAtBottomProtectionStandardDeviation' REAL, + 'ConstructiveStrengthLinearLoadModelMean' REAL, + 'ConstructiveStrengthLinearLoadModelCoefficientOfVariation' REAL, + 'ConstructiveStrengthQuadraticLoadModelMean' REAL, + 'ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation' REAL, + 'BankWidthMean' REAL, + 'BankWidthStandardDeviation' REAL, + 'InsideWaterLevelFailureConstructionMean' REAL, + 'InsideWaterLevelFailureConstructionStandardDeviation' REAL, + 'EvaluationLevel' REAL, + 'LevelCrestStructureMean' REAL, + 'LevelCrestStructureStandardDeviation' REAL, + 'VerticalDistance' REAL, + 'FailureProbabilityRepairClosure' REAL NOT NULL, + 'FailureCollisionEnergyMean' REAL, + 'FailureCollisionEnergyCoefficientOfVariation' REAL, + 'ShipMassMean' REAL, + 'ShipMassCoefficientOfVariation' REAL, + 'ShipVelocityMean' REAL, + 'ShipVelocityCoefficientOfVariation' REAL, + 'LevellingCount' INT (4) NOT NULL, + 'ProbabilityCollisionSecondaryStructure' REAL NOT NULL, + 'FlowVelocityStructureClosableMean' REAL, + 'StabilityLinearLoadModelMean' REAL, + 'StabilityLinearLoadModelCoefficientOfVariation' REAL, + 'StabilityQuadraticLoadModelMean' REAL, + 'StabilityQuadraticLoadModelCoefficientOfVariation' REAL, + 'AreaFlowAperturesMean' REAL, + 'AreaFlowAperturesStandardDeviation' REAL, + 'InflowModelType' TINYINT (1) NOT NULL, -- Enum: 1 = VerticalWall, 2 = LowSill, 3 = FloodedCulvert + 'LoadSchematizationType' TINYINT (1) NOT NULL, -- Enum: 1 = Linear, 2 = Quadratic + 'VolumicWeightWater' REAL, + 'StormDurationMean' REAL, + 'ModelFactorSuperCriticalFlowMean' REAL, + 'FactorStormDurationOpenStructure' REAL, + 'DrainCoefficientMean' REAL, + 'FailureProbabilityStructureWithErosion' REAL NOT NULL, + CONSTRAINT 'FK_StabilityPointStructuresCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_StabilityPointStructuresCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade, + CONSTRAINT 'FK_StabilityPointStructuresCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade, + CONSTRAINT 'FK_StabilityPointStructuresCalculationEntity_StabilityPointStructureEntity' FOREIGN KEY ('StabilityPointStructureEntityId') REFERENCES 'StabilityPointStructureEntity' ('StabilityPointStructureEntityId') ON DELETE Set Null ON UPDATE Cascade +) +; + +CREATE TABLE 'AssessmentSectionEntity' +( + 'AssessmentSectionEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'ProjectEntityId' INTEGER NOT NULL, + 'Id' TEXT, + 'Name' VARCHAR (260), + 'Comments' TEXT, + 'Norm' REAL NOT NULL, + 'HydraulicDatabaseVersion' TEXT, + 'HydraulicDatabaseLocation' TEXT, + 'Composition' TINYINT (1) NOT NULL, -- Enum: 1 = Dike, 2 = Dune, 3 = DikeAndDune + 'ReferenceLinePointXml' TEXT, + 'Order' INT (4) NOT NULL, + CONSTRAINT 'FK_AssessmentSectionEntity_ProjectEntity' FOREIGN KEY ('ProjectEntityId') REFERENCES 'ProjectEntity' ('ProjectEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'FailureMechanismEntity' +( + 'FailureMechanismEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'AssessmentSectionEntityId' INTEGER NOT NULL, + 'CalculationGroupEntityId' INTEGER, + 'FailureMechanismType' SMALLINT NOT NULL, -- Enum: 1 = Piping, 2 = Macrostabiliteit binnenwaarts, 3= Golfklappen op asfaltbekleding, 4= Grasbekleding erosie buitentalud, 5 = Grasbekleding afschuiven buitentalud, 6 = Grasbekleding erosie kruin en binnentalud, 7 = Stabiliteit steenzetting, 8 = Duinafslag, 9 = Hoogte kunstwerk, 10 = Betrouwbaarheid sluiten kunstwerk, 11 = Piping bij kunstwerk, 12 = Sterkte en stabiliteit puntconstructires, 13 = Macrostabiliteit buitenwaarts, 14 = Microstabiliteit, 15 = Wateroverdruk bij asfaltbekleding, 16 = Grasbekleding afschuiven binnentalud, 17 = Sterkte en stabiliteit langsconstructires, 18 = Technische innovaties + 'IsRelevant' TINYINT (1) NOT NULL, -- true or false + 'InputComments' TEXT, + 'OutputComments' TEXT, + 'NotRelevantComments' TEXT, + CONSTRAINT 'FK_FailureMechanismEntity_AssessmentSectionEntity' FOREIGN KEY ('AssessmentSectionEntityId') REFERENCES 'AssessmentSectionEntity' ('AssessmentSectionEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_FailureMechanismEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'UI_AssessmentSectionEntityId_FailureMechanismType' UNIQUE ('AssessmentSectionEntityId','FailureMechanismType') +) +; + +CREATE TABLE 'FailureMechanismSectionEntity' +( + 'FailureMechanismSectionEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'Name' VARCHAR (260) NOT NULL, + 'FailureMechanismSectionPointXml' TEXT NOT NULL, + CONSTRAINT 'FK_FailureMechanismSectionEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'PipingFailureMechanismMetaEntity' +( + 'PipingFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'A' REAL NOT NULL, + 'WaterVolumetricWeight' REAL NOT NULL, + 'StochasticSoilModelSourcePath' TEXT, + CONSTRAINT 'FK_PipingFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'StabilityPointStructuresFailureMechanismMetaEntity' +( + 'StrengthStabilityPointConstructionFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'N' INT (4) NOT NULL, + CONSTRAINT 'FK_StrengthStabilityPointConstructionFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'ClosingStructuresFailureMechanismMetaEntity' +( + 'ClosingStructuresFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'N2A' INT (4) NOT NULL, + CONSTRAINT 'FK_ClosingStructuresFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'DuneErosionFailureMechanismMetaEntity' +( + 'DuneErosionFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'N' REAL NOT NULL, + CONSTRAINT 'FK_DuneErosionFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'CalculationGroupEntity' +( + 'CalculationGroupEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'ParentCalculationGroupEntityId' INTEGER, + 'Name' VARCHAR (260), + 'Order' INT (4) NOT NULL, + CONSTRAINT 'FK_CalculationGroupEntity_CalculationGroupEntity' FOREIGN KEY ('ParentCalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'HeightStructuresFailureMechanismMetaEntity' +( + 'HeightStructuresFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'N' INT (4) NOT NULL, + CONSTRAINT 'FK_HeightStructuresFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'HydraulicLocationEntity' +( + 'HydraulicLocationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'AssessmentSectionEntityId' INTEGER NOT NULL, + 'LocationId' INTEGER NOT NULL, + 'Name' VARCHAR (260) NOT NULL, + 'LocationX' REAL, + 'LocationY' REAL, + 'Order' INT (4) NOT NULL, + CONSTRAINT 'FK_HydraulicLocationEntity_AssessmentSectionEntity' FOREIGN KEY ('AssessmentSectionEntityId') REFERENCES 'AssessmentSectionEntity' ('AssessmentSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'PipingCalculationEntity' +( + 'PipingCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'CalculationGroupEntityId' INTEGER NOT NULL, + 'SurfaceLineEntityId' INTEGER, + 'StochasticSoilProfileEntityId' INTEGER, + 'HydraulicLocationEntityId' INTEGER, + 'Order' INT (4) NOT NULL, + 'Name' VARCHAR (260), + 'Comments' TEXT, + 'EntryPointL' REAL, + 'ExitPointL' REAL, + 'PhreaticLevelExitMean' REAL, + 'PhreaticLevelExitStandardDeviation' REAL, + 'DampingFactorExitMean' REAL, + 'DampingFactorExitStandardDeviation' REAL, + 'RelevantForScenario' TINYINT (1) NOT NULL, -- true or false + 'ScenarioContribution' REAL, + 'AssessmentLevel' REAL, + 'UseAssessmentLevelManualInput' TINYINT (1) NOT NULL, -- true or false + CONSTRAINT 'FK_PipingCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_PipingCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade, + CONSTRAINT 'FK_PipingCalculationEntity_StochasticSoilProfileEntity' FOREIGN KEY ('StochasticSoilProfileEntityId') REFERENCES 'StochasticSoilProfileEntity' ('StochasticSoilProfileEntityId') ON DELETE Set Null ON UPDATE Cascade, + CONSTRAINT 'FK_PipingCalculationEntity_SurfaceLineEntity' FOREIGN KEY ('SurfaceLineEntityId') REFERENCES 'SurfaceLineEntity' ('SurfaceLineEntityId') ON DELETE Set Null ON UPDATE Cascade +) +; + +CREATE TABLE 'GrassCoverErosionInwardsFailureMechanismMetaEntity' +( + 'GrassCoverErosionInwardsFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'N' INT (4) NOT NULL, + CONSTRAINT 'FK_GrassCoverErosionInwardsFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'GrassCoverErosionInwardsCalculationEntity' +( + 'GrassCoverErosionInwardsCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'CalculationGroupEntityId' INTEGER NOT NULL, + 'HydraulicLocationEntityId' INTEGER, + 'DikeProfileEntityId' INTEGER, + 'Order' INT (4) NOT NULL, + 'Name' VARCHAR (260), + 'Comments' TEXT, + 'Orientation' REAL, + 'CriticalFlowRateMean' REAL, + 'CriticalFlowRateStandardDeviation' REAL, + 'UseForeshore' TINYINT (1) NOT NULL, -- true or false + 'DikeHeightCalculationType' TINYINT (1) NOT NULL, -- Enum: 1 = NoCalculation, 2 = CalculateByAssessmentSectionNorm, 3 = CalculateByProfileSpecificRequiredProbability + 'DikeHeight' REAL, + 'UseBreakWater' TINYINT (1) NOT NULL, -- true or false + 'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam + 'BreakWaterHeight' REAL, + CONSTRAINT 'FK_GrassCoverErosionInwardsCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_GrassCoverErosionInwardsCalculationEntity_DikeProfileEntity' FOREIGN KEY ('DikeProfileEntityId') REFERENCES 'DikeProfileEntity' ('DikeProfileEntityId') ON DELETE Set Null ON UPDATE Cascade, + CONSTRAINT 'FK_GrassCoverErosionInwardsCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade +) +; + +CREATE TABLE 'GrassCoverErosionOutwardsFailureMechanismMetaEntity' +( + 'GrassCoverErosionOutwardsFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'N' INT (4) NOT NULL, + CONSTRAINT 'FK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'SoilLayerEntity' +( + 'SoilLayerEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'SoilProfileEntityId' INTEGER NOT NULL, + 'Top' REAL, + 'IsAquifer' TINYINT (1) NOT NULL, -- true or false + 'Color' INTEGER NOT NULL, -- ARGB value of Color. + 'MaterialName' TEXT NOT NULL, + 'BelowPhreaticLevelMean' REAL, + 'BelowPhreaticLevelDeviation' REAL, + 'DiameterD70Mean' REAL, + 'DiameterD70Deviation' REAL, + 'BelowPhreaticLevelShift' REAL, + 'PermeabilityMean' REAL, + 'PermeabilityDeviation' REAL, + 'Order' INT (4) NOT NULL, + CONSTRAINT 'FK_SoilLayerEntity_SoilProfileEntity' FOREIGN KEY ('SoilProfileEntityId') REFERENCES 'SoilProfileEntity' ('SoilProfileEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'SoilProfileEntity' +( + 'SoilProfileEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'Bottom' REAL, + 'Name' TEXT +) +; + +CREATE TABLE 'StochasticSoilProfileEntity' +( + 'StochasticSoilProfileEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'SoilProfileEntityId' INTEGER NOT NULL, + 'StochasticSoilModelEntityId' INTEGER NOT NULL, + 'Probability' REAL, + 'Order' INT (4) NOT NULL, + CONSTRAINT 'FK_StochasticSoilProfileEntity_SoilProfileEntity' FOREIGN KEY ('SoilProfileEntityId') REFERENCES 'SoilProfileEntity' ('SoilProfileEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_StochasticSoilProfileEntity_StochasticSoilModelEntity' FOREIGN KEY ('StochasticSoilModelEntityId') REFERENCES 'StochasticSoilModelEntity' ('StochasticSoilModelEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'StochasticSoilModelEntity' +( + 'StochasticSoilModelEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'Name' TEXT, + 'SegmentName' TEXT, + 'StochasticSoilModelSegmentPointXml' TEXT NOT NULL, + 'Order' INT (4) NOT NULL, + CONSTRAINT 'FK_StochasticSoilModelEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'SurfaceLineEntity' +( + 'SurfaceLineEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'Name' VARCHAR (260), + 'ReferenceLineIntersectionX' REAL, + 'ReferenceLineIntersectionY' REAL, + 'PointsXml' TEXT NOT NULL, + 'Order' INT (4) NOT NULL, + CONSTRAINT 'FK_SurfaceLineEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'CharacteristicPointEntity' +( + 'CharacteristicPointEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'SurfaceLineEntityId' INTEGER NOT NULL, + 'Type' TINYINT (1) NOT NULL, -- Enum: 1 = DikeToeAtRiver, 2 = DikeToeAtPolder, 3 = DitchDikeSide, 4 = BottomDitchDikeSide, 5 = BottomDitchPolderSide, 6 = DitchPolderSide + 'X' REAL, + 'Y' REAL, + 'Z' REAL, + CONSTRAINT 'FK_SurfaceLinePointEntity_SurfaceLineEntity' FOREIGN KEY ('SurfaceLineEntityId') REFERENCES 'SurfaceLineEntity' ('SurfaceLineEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'PipingCalculationOutputEntity' +( + 'PipingCalculationOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'PipingCalculationEntityId' INTEGER NOT NULL, + 'Order' INT (4) NOT NULL, + 'HeaveFactorOfSafety' REAL, + 'HeaveZValue' REAL, + 'UpliftFactorOfSafety' REAL, + 'UpliftZValue' REAL, + 'SellmeijerFactorOfSafety' REAL, + 'SellmeijerZValue' REAL, + 'UpliftEffectiveStress' REAL, + 'HeaveGradient' REAL, + 'SellmeijerCreepCoefficient' REAL, + 'SellmeijerCriticalFall' REAL, + 'SellmeijerReducedFall' REAL, + CONSTRAINT 'FK_PipingCalculationOutputEntity_PipingCalculationEntity' FOREIGN KEY ('PipingCalculationEntityId') REFERENCES 'PipingCalculationEntity' ('PipingCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'U_PipingCalculationEntity' UNIQUE ('PipingCalculationEntityId') +) +; + +CREATE TABLE 'PipingSemiProbabilisticOutputEntity' +( + 'PipingSemiProbabilisticOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'PipingCalculationEntityId' INTEGER NOT NULL, + 'Order' INT (4) NOT NULL, + 'UpliftFactorOfSafety' REAL, + 'UpliftReliability' REAL, + 'UpliftProbability' REAL, + 'HeaveFactorOfSafety' REAL, + 'HeaveReliability' REAL, + 'HeaveProbability' REAL, + 'SellmeijerFactorOfSafety' REAL, + 'SellmeijerReliability' REAL, + 'SellmeijerProbability' REAL, + 'RequiredProbability' REAL, + 'RequiredReliability' REAL, + 'PipingProbability' REAL, + 'PipingReliability' REAL, + 'PipingFactorOfSafety' REAL, + CONSTRAINT 'FK_PipingSemiProbabilisticOutputEntity_PipingCalculationEntity' FOREIGN KEY ('PipingCalculationEntityId') REFERENCES 'PipingCalculationEntity' ('PipingCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'U_PipingCalculationEntity' UNIQUE ('PipingCalculationEntityId') +) +; + +CREATE TABLE 'PipingSectionResultEntity' +( + 'PipingSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerThree' REAL, + CONSTRAINT 'FK_PipingSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'GrassCoverErosionInwardsSectionResultEntity' +( + 'GrassCoverErosionInwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'GrassCoverErosionInwardsCalculationEntityId' INTEGER, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerThree' REAL, + CONSTRAINT 'FK_GrassCoverErosionInwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_GrassCoverErosionInwardsSectionResultEntity_GrassCoverErosionInwardsCalculationEntity' FOREIGN KEY ('GrassCoverErosionInwardsCalculationEntityId') REFERENCES 'GrassCoverErosionInwardsCalculationEntity' ('GrassCoverErosionInwardsCalculationEntityId') ON DELETE Set Null ON UPDATE Cascade +) +; + +CREATE TABLE 'HeightStructuresSectionResultEntity' +( + 'HeightStructuresSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'HeightStructuresCalculationEntityId' INTEGER, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerThree' REAL, + CONSTRAINT 'FK_HeightStructuresSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_HeightStructuresSectionResultEntity_HeightStructuresCalculationEntity' FOREIGN KEY ('HeightStructuresCalculationEntityId') REFERENCES 'HeightStructuresCalculationEntity' ('HeightStructuresCalculationEntityId') ON DELETE Set Null ON UPDATE Cascade +) +; + +CREATE TABLE 'StrengthStabilityLengthwiseConstructionSectionResultEntity' +( + 'StrengthStabilityLengthwiseConstructionSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerThree' REAL, + CONSTRAINT 'FK_StrengthStabilityLengthwiseConstructionSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'TechnicalInnovationSectionResultEntity' +( + 'TechnicalInnovationSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerThree' REAL, + CONSTRAINT 'FK_TechnicalInnovationSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'WaterPressureAsphaltCoverSectionResultEntity' +( + 'WaterPressureAsphaltCoverSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerThree' REAL, + CONSTRAINT 'FK_WaterPressureAsphaltCoverSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'ClosingStructuresSectionResultEntity' +( + 'ClosingStructuresSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'ClosingStructuresCalculationEntityId' INTEGER, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerThree' REAL, + CONSTRAINT 'FK_ClosingStructuresSectionResultEntity_ClosingStructuresCalculationEntity' FOREIGN KEY ('ClosingStructuresCalculationEntityId') REFERENCES 'ClosingStructuresCalculationEntity' ('ClosingStructuresCalculationEntityId') ON DELETE Set Null ON UPDATE Cascade, + CONSTRAINT 'FK_ClosingStructuresSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'GrassCoverErosionOutwardsSectionResultEntity' +( + 'GrassCoverErosionOutwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerTwoA' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = Failed, 3 = Successful + 'LayerThree' REAL, + CONSTRAINT 'FK_GrassCoverErosionOutwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'GrassCoverSlipOffInwardsSectionResultEntity' +( + 'GrassCoverSlipOffInwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerTwoA' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = Failed, 3 = Successful + 'LayerThree' REAL, + CONSTRAINT 'FK_GrassCoverSlipOffInwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'GrassCoverSlipOffOutwardsSectionResultEntity' +( + 'GrassCoverSlipOffOutwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerTwoA' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = Failed, 3 = Successful + 'LayerThree' REAL, + CONSTRAINT 'FK_GrassCoverSlipOffOutwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'MacrostabilityInwardsSectionResultEntity' +( + 'MacrostabilityInwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerTwoA' REAL, + 'LayerThree' REAL, + CONSTRAINT 'FK_MacrostabilityInwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'MacrostabilityOutwardsSectionResultEntity' +( + 'MacrostabilityOutwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerTwoA' REAL, + 'LayerThree' REAL, + CONSTRAINT 'FK_MacrostabilityOutwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'WaveImpactAsphaltCoverSectionResultEntity' +( + 'WaveImpactAsphaltCoverSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerTwoA' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = Failed, 3 = Successful + 'LayerThree' REAL, + CONSTRAINT 'FK_WaveImpactAsphaltCoverSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'MicrostabilitySectionResultEntity' +( + 'MicrostabilitySectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerTwoA' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = Failed, 3 = Successful + 'LayerThree' REAL, + CONSTRAINT 'FK_MicrostabilitySectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'PipingStructureSectionResultEntity' +( + 'PipingStructureSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerTwoA' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = Failed, 3 = Successful + 'LayerThree' REAL, + CONSTRAINT 'FK_PipingStructureSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'DuneErosionSectionResultEntity' +( + 'DuneErosionSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerTwoA' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = Failed, 3 = Successful + 'LayerThree' REAL, + CONSTRAINT 'FK_DuneErosionSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'StabilityStoneCoverSectionResultEntity' +( + 'StabilityStoneCoverSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerTwoA' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = Failed, 3 = Successful + 'LayerThree' REAL, + CONSTRAINT 'FK_StabilityStoneCoverSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'StabilityPointStructuresSectionResultEntity' +( + 'StabilityPointStructuresSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'StabilityPointStructuresCalculationEntityId' INTEGER, + 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict + 'LayerThree' REAL, + CONSTRAINT 'FK_StabilityPointStructuresSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_StabilityPointStructuresSectionResultEntity_StabilityPointStructuresCalculationEntity' FOREIGN KEY ('StabilityPointStructuresCalculationEntityId') REFERENCES 'StabilityPointStructuresCalculationEntity' ('StabilityPointStructuresCalculationEntityId') ON DELETE Set Null ON UPDATE Cascade +) +; + +CREATE TABLE 'DikeProfileEntity' +( + 'DikeProfileEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'Name' VARCHAR (260) NOT NULL, + 'Orientation' REAL, + 'BreakWaterType' TINYINT (1), -- Enum: 1 = Wall 2 = Caisson 3 = Dam + 'BreakWaterHeight' REAL, + 'ForeshoreXml' TEXT NOT NULL, + 'DikeGeometryXml' TEXT NOT NULL, + 'DikeHeight' REAL, + 'X' REAL, + 'Y' REAL, + 'X0' REAL, + 'Order' INT (4) NOT NULL, + CONSTRAINT 'FK_DikeProfileEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'GrassCoverErosionInwardsOutputEntity' +( + 'GrassCoverErosionInwardsOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'GrassCoverErosionInwardsCalculationEntityId' INTEGER NOT NULL, + 'Order' INT (4) NOT NULL, + 'IsOvertoppingDominant' TINYINT (1) NOT NULL, -- true or false + 'WaveHeight' REAL, + 'RequiredProbability' REAL, + 'RequiredReliability' REAL, + 'Probability' REAL, + 'Reliability' REAL, + 'FactorOfSafety' REAL, + CONSTRAINT 'FK_GrassCoverErosionInwardsOutputEntity_GrassCoverErosionInwardsCalculationEntity' FOREIGN KEY ('GrassCoverErosionInwardsCalculationEntityId') REFERENCES 'GrassCoverErosionInwardsCalculationEntity' ('GrassCoverErosionInwardsCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'U_GrassCoverErosionInwardsCalculationEntity' UNIQUE ('GrassCoverErosionInwardsCalculationEntityId') +) +; + +CREATE TABLE 'ForeshoreProfileEntity' +( + 'ForeshoreProfileEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'Name' VARCHAR (260), + 'Orientation' REAL, + 'BreakWaterType' TINYINT (1), -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam + 'BreakWaterHeight' REAL, + 'GeometryXml' TEXT NOT NULL, + 'X' REAL, + 'Y' REAL, + 'X0' REAL, + 'Order' INT (4) NOT NULL, + CONSTRAINT 'FK_ForeshoreProfileEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'StabilityStoneCoverWaveConditionsCalculationEntity' +( + 'StabilityStoneCoverWaveConditionsCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'CalculationGroupEntityId' INTEGER NOT NULL, + 'ForeshoreProfileEntityId' INTEGER, + 'HydraulicLocationEntityId' INTEGER, + 'Order' INT (4) NOT NULL, + 'Name' VARCHAR (260), + 'Comments' TEXT, + 'UseBreakWater' TINYINT (1) NOT NULL, -- true or false + 'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam + 'BreakWaterHeight' REAL, + 'UseForeshore' TINYINT (1) NOT NULL, -- true or false + 'Orientation' REAL, + 'UpperBoundaryRevetment' REAL, + 'LowerBoundaryRevetment' REAL, + 'UpperBoundaryWaterLevels' REAL, + 'LowerBoundaryWaterLevels' REAL, + 'StepSize' TINYINT (1) NOT NULL, -- Enum: 1 = 0.5, 2 = 1.0, 3 = 2.0 + CONSTRAINT 'FK_StabilityStoneCoverWaveConditionsCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_StabilityStoneCoverWaveConditionsCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade, + CONSTRAINT 'FK_StabilityStoneCoverWaveConditionsCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade +) +; + +CREATE TABLE 'StabilityStoneCoverWaveConditionsOutputEntity' +( + 'StabilityStoneCoverWaveConditionsOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'StabilityStoneCoverWaveConditionsCalculationEntityId' INTEGER NOT NULL, + 'Order' INT (4) NOT NULL, + 'OutputType' TINYINT (1) NOT NULL, -- Enum: 1 = Column, 2 = Block + 'WaterLevel' REAL, + 'WaveHeight' REAL, + 'WavePeakPeriod' REAL, + 'WaveAngle' REAL, + 'WaveDirection' REAL, + 'TargetProbability' REAL, + 'TargetReliability' REAL, + 'CalculatedProbability' REAL, + 'CalculatedReliability' REAL, + 'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculationNotConverged, 3 = CalculationConverged + CONSTRAINT 'FK_StabilityStoneCoverWaveConditionsOutputEntity_StabilityStoneCoverWaveConditionsCalculationEntity' FOREIGN KEY ('StabilityStoneCoverWaveConditionsCalculationEntityId') REFERENCES 'StabilityStoneCoverWaveConditionsCalculationEntity' ('StabilityStoneCoverWaveConditionsCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'WaveImpactAsphaltCoverWaveConditionsCalculationEntity' +( + 'WaveImpactAsphaltCoverWaveConditionsCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'CalculationGroupEntityId' INTEGER NOT NULL, + 'ForeshoreProfileEntityId' INTEGER, + 'HydraulicLocationEntityId' INTEGER, + 'Order' INT (4) NOT NULL, + 'Name' VARCHAR (260), + 'Comments' TEXT, + 'UseBreakWater' TINYINT (1) NOT NULL, -- true or false + 'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam + 'BreakWaterHeight' REAL, + 'UseForeshore' TINYINT (1) NOT NULL, -- true or false + 'Orientation' REAL, + 'UpperBoundaryRevetment' REAL, + 'LowerBoundaryRevetment' REAL, + 'UpperBoundaryWaterLevels' REAL, + 'LowerBoundaryWaterLevels' REAL, + 'StepSize' TINYINT (1) NOT NULL, -- Enum: 1 = 0.5, 2 = 1.0, 3 = 2.0 + CONSTRAINT 'FK_WaveImpactAsphaltCoverWaveConditionsCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_WaveImpactAsphaltCoverWaveConditionsCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade, + CONSTRAINT 'FK_WaveImpactAsphaltCoverWaveConditionsCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade +) +; + +CREATE TABLE 'WaveImpactAsphaltCoverWaveConditionsOutputEntity' +( + 'WaveImpactAsphaltCoverWaveConditionsOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'WaveImpactAsphaltCoverWaveConditionsCalculationEntityId' INTEGER NOT NULL, + 'Order' INT (4) NOT NULL, + 'WaterLevel' REAL, + 'WaveHeight' REAL, + 'WavePeakPeriod' REAL, + 'WaveAngle' REAL, + 'WaveDirection' REAL, + 'TargetProbability' REAL, + 'TargetReliability' REAL, + 'CalculatedProbability' REAL, + 'CalculatedReliability' REAL, + 'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculationNotConverged, 3 = CalculationConverged + CONSTRAINT 'FK_WaveImpactAsphaltCoverWaveConditionsOutputEntity_WaveImpactAsphaltCoverWaveConditionsCalculationEntity' FOREIGN KEY ('WaveImpactAsphaltCoverWaveConditionsCalculationEntityId') REFERENCES 'WaveImpactAsphaltCoverWaveConditionsCalculationEntity' ('WaveImpactAsphaltCoverWaveConditionsCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'GrassCoverErosionOutwardsWaveConditionsCalculationEntity' +( + 'GrassCoverErosionOutwardsWaveConditionsCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'CalculationGroupEntityId' INTEGER NOT NULL, + 'ForeshoreProfileEntityId' INTEGER, + 'GrassCoverErosionOutwardsHydraulicLocationEntityId' INTEGER, + 'Order' INT (4) NOT NULL, + 'Name' VARCHAR (260), + 'Comments' TEXT, + 'UseBreakWater' TINYINT (1) NOT NULL, -- true or false + 'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam + 'BreakWaterHeight' REAL, + 'UseForeshore' TINYINT (1) NOT NULL, -- true or false + 'Orientation' REAL, + 'UpperBoundaryRevetment' REAL, + 'LowerBoundaryRevetment' REAL, + 'UpperBoundaryWaterLevels' REAL, + 'LowerBoundaryWaterLevels' REAL, + 'StepSize' TINYINT (1) NOT NULL, -- Enum: 1 = 0.5, 2 = 1.0, 3 = 2.0 + CONSTRAINT 'FK_GrassCoverErosionOutwardsWaveConditionsCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_GrassCoverErosionOutwardsWaveConditionsCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade, + CONSTRAINT 'FK_GrassCoverErosionOutwardsWaveConditionsCalculationEntity_GrassCoverErosionOutwardsHydraulicLocationEntity' FOREIGN KEY ('GrassCoverErosionOutwardsHydraulicLocationEntityId') REFERENCES 'GrassCoverErosionOutwardsHydraulicLocationEntity' ('GrassCoverErosionOutwardsHydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade +) +; + +CREATE TABLE 'GrassCoverErosionOutwardsHydraulicLocationEntity' +( + 'GrassCoverErosionOutwardsHydraulicLocationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'LocationId' INTEGER NOT NULL, + 'Name' VARCHAR (260) NOT NULL, + 'LocationX' REAL, + 'LocationY' REAL, + 'Order' INT (4) NOT NULL, + CONSTRAINT 'FK_GrassCoverErosionOutwardsHydraulicLocationEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'GrassCoverErosionOutwardsWaveConditionsOutputEntity' +( + 'GrassCoverErosionOutwardsWaveConditionsOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'GrassCoverErosionOutwardsWaveConditionsCalculationEntityId' INTEGER NOT NULL, + 'Order' INT (4) NOT NULL, + 'WaterLevel' REAL, + 'WaveHeight' REAL, + 'WavePeakPeriod' REAL, + 'WaveAngle' REAL, + 'WaveDirection' REAL, + 'TargetProbability' REAL, + 'TargetReliability' REAL, + 'CalculatedProbability' REAL, + 'CalculatedReliability' REAL, + 'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculationNotConverged, 3 = CalculationConverged + CONSTRAINT 'FK_GrassCoverErosionOutwardsWaveConditionsOutputEntity_GrassCoverErosionOutwardsWaveConditionsCalculationEntity' FOREIGN KEY ('GrassCoverErosionOutwardsWaveConditionsCalculationEntityId') REFERENCES 'GrassCoverErosionOutwardsWaveConditionsCalculationEntity' ('GrassCoverErosionOutwardsWaveConditionsCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'HeightStructuresOutputEntity' +( + 'HeightStructuresOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'HeightStructuresCalculationEntityId' INTEGER NOT NULL, + 'RequiredProbability' REAL, + 'RequiredReliability' REAL, + 'Probability' REAL, + 'Reliability' REAL, + 'FactorOfSafety' REAL, + CONSTRAINT 'FK_HeightStructuresOutputEntity_HeightStructuresCalculationEntity' FOREIGN KEY ('HeightStructuresCalculationEntityId') REFERENCES 'HeightStructuresCalculationEntity' ('HeightStructuresCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'U_HeightStructuresCalculationEntity' UNIQUE ('HeightStructuresCalculationEntityId') +) +; + +CREATE TABLE 'HeightStructureEntity' +( + 'HeightStructureEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'Order' INT (4) NOT NULL, + 'Name' VARCHAR (260), + 'Id' VARCHAR (260), + 'X' REAL, + 'Y' REAL, + 'StructureNormalOrientation' REAL, + 'LevelCrestStructureMean' REAL, + 'LevelCrestStructureStandardDeviation' REAL, + 'FlowWidthAtBottomProtectionMean' REAL, + 'FlowWidthAtBottomProtectionStandardDeviation' REAL, + 'CriticalOvertoppingDischargeMean' REAL, + 'CriticalOvertoppingDischargeCoefficientOfVariation' REAL, + 'WidthFlowAperturesMean' REAL, + 'WidthFlowAperturesStandardDeviation' REAL, + 'FailureProbabilityStructureWithErosion' REAL, + 'StorageStructureAreaMean' REAL, + 'StorageStructureAreaCoefficientOfVariation' REAL, + 'AllowedLevelIncreaseStorageMean' REAL, + 'AllowedLevelIncreaseStorageStandardDeviation' REAL, + CONSTRAINT 'FK_HeightStructure_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'HeightStructuresCalculationEntity' +( + 'HeightStructuresCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'CalculationGroupEntityId' INTEGER NOT NULL, + 'HydraulicLocationEntityId' INTEGER, + 'HeightStructureEntityId' INTEGER, + 'ForeshoreProfileEntityId' INTEGER, + 'Order' INT (4) NOT NULL, + 'Name' VARCHAR (260), + 'Comments' TEXT, + 'ModelFactorSuperCriticalFlowMean' REAL, + 'StructureNormalOrientation' REAL, + 'AllowedLevelIncreaseStorageMean' REAL, + 'AllowedLevelIncreaseStorageStandardDeviation' REAL, + 'StorageStructureAreaMean' REAL, + 'StorageStructureAreaCoefficientOfVariation' REAL, + 'FlowWidthAtBottomProtectionMean' REAL, + 'FlowWidthAtBottomProtectionStandardDeviation' REAL, + 'CriticalOvertoppingDischargeMean' REAL, + 'CriticalOvertoppingDischargeCoefficientOfVariation' REAL, + 'FailureProbabilityStructureWithErosion' REAL NOT NULL, + 'WidthFlowAperturesMean' REAL, + 'WidthFlowAperturesStandardDeviation' REAL, + 'StormDurationMean' REAL, + 'LevelCrestStructureMean' REAL, + 'LevelCrestStructureStandardDeviation' REAL, + 'DeviationWaveDirection' REAL, + 'UseBreakWater' TINYINT (1) NOT NULL, -- true or false + 'UseForeshore' TINYINT (1) NOT NULL, -- true or false + 'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam + 'BreakWaterHeight' REAL, + CONSTRAINT 'FK_HeightStructuresCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_HeightStructuresCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade, + CONSTRAINT 'FK_HeightStructuresCalculationEntity_HeightStructureEntity' FOREIGN KEY ('HeightStructureEntityId') REFERENCES 'HeightStructureEntity' ('HeightStructureEntityId') ON DELETE Set Null ON UPDATE Cascade, + CONSTRAINT 'FK_HeightStructuresCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade +) +; + +CREATE TABLE 'ClosingStructureEntity' +( + 'ClosingStructureEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'Order' INT (4) NOT NULL, + 'Name' VARCHAR (260), + 'Id' VARCHAR (260), + 'X' REAL, + 'Y' REAL, + 'StructureNormalOrientation' REAL, + 'StorageStructureAreaMean' REAL, + 'StorageStructureAreaCoefficientOfVariation' REAL, + 'AllowedLevelIncreaseStorageMean' REAL, + 'AllowedLevelIncreaseStorageStandardDeviation' REAL, + 'WidthFlowAperturesMean' REAL, + 'WidthFlowAperturesStandardDeviation' REAL, + 'LevelCrestStructureNotClosingMean' REAL, + 'LevelCrestStructureNotClosingStandardDeviation' REAL, + 'InsideWaterLevelMean' REAL, + 'InsideWaterLevelStandardDeviation' REAL, + 'ThresholdHeightOpenWeirMean' REAL, + 'ThresholdHeightOpenWeirStandardDeviation' REAL, + 'AreaFlowAperturesMean' REAL, + 'AreaFlowAperturesStandardDeviation' REAL, + 'CriticalOvertoppingDischargeMean' REAL, + 'CriticalOvertoppingDischargeCoefficientOfVariation' REAL, + 'FlowWidthAtBottomProtectionMean' REAL, + 'FlowWidthAtBottomProtectionStandardDeviation' REAL, + 'ProbabilityOrFrequencyOpenStructureBeforeFlooding' REAL, + 'FailureProbabilityOpenStructure' REAL, + 'IdenticalApertures' INT (4) NOT NULL, + 'FailureProbabilityReparation' REAL, + 'InflowModelType' TINYINT (1) NOT NULL, -- Enum: 1 = VerticalWall, 2 = LowSill, 3 = FloodedCulvert + CONSTRAINT 'FK_ClosingStructureEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'ClosingStructuresCalculationEntity' +( + 'ClosingStructuresCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'CalculationGroupEntityId' INTEGER NOT NULL, + 'ForeshoreProfileEntityId' INTEGER, + 'HydraulicLocationEntityId' INTEGER, + 'ClosingStructureEntityId' INTEGER, + 'Order' INT (4) NOT NULL, + 'Name' VARCHAR (255), + 'Comments' TEXT, + 'UseBreakWater' TINYINT (1) NOT NULL, -- true or false + 'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam + 'BreakWaterHeight' REAL, + 'UseForeshore' TINYINT (1) NOT NULL, -- true or false + 'Orientation' REAL, + 'StructureNormalOrientation' REAL, + 'StorageStructureAreaMean' REAL, + 'StorageStructureAreaCoefficientOfVariation' REAL, + 'AllowedLevelIncreaseStorageMean' REAL, + 'AllowedLevelIncreaseStorageStandardDeviation' REAL, + 'WidthFlowAperturesMean' REAL, + 'WidthFlowAperturesStandardDeviation' REAL, + 'LevelCrestStructureNotClosingMean' REAL, + 'LevelCrestStructureNotClosingStandardDeviation' REAL, + 'InsideWaterLevelMean' REAL, + 'InsideWaterLevelStandardDeviation' REAL, + 'ThresholdHeightOpenWeirMean' REAL, + 'ThresholdHeightOpenWeirStandardDeviation' REAL, + 'AreaFlowAperturesMean' REAL, + 'AreaFlowAperturesStandardDeviation' REAL, + 'CriticalOvertoppingDischargeMean' REAL, + 'CriticalOvertoppingDischargeCoefficientOfVariation' REAL, + 'FlowWidthAtBottomProtectionMean' REAL, + 'FlowWidthAtBottomProtectionStandardDeviation' REAL, + 'ProbabilityOrFrequencyOpenStructureBeforeFlooding' REAL NOT NULL, + 'FailureProbabilityOpenStructure' REAL NOT NULL, + 'IdenticalApertures' INT (4) NOT NULL, + 'FailureProbabilityReparation' REAL NOT NULL, + 'InflowModelType' TINYINT (1) NOT NULL, -- Enum: 1 = VerticalWall, 2 = LowSill, 3 = FloodedCulvert + 'FailureProbabilityStructureWithErosion' REAL NOT NULL, + 'DeviationWaveDirection' REAL, + 'DrainCoefficientMean' REAL, + 'ModelFactorSuperCriticalFlowMean' REAL, + 'StormDurationMean' REAL, + 'FactorStormDurationOpenStructure' REAL, + CONSTRAINT 'FK_ClosingStructuresCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_ClosingStructuresCalculationEntity_ClosingStructureEntity' FOREIGN KEY ('ClosingStructureEntityId') REFERENCES 'ClosingStructureEntity' ('ClosingStructureEntityId') ON DELETE Set Null ON UPDATE Cascade, + CONSTRAINT 'FK_ClosingStructuresCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade, + CONSTRAINT 'FK_ClosingStructuresCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade +) +; + +CREATE TABLE 'ClosingStructuresOutputEntity' +( + 'ClosingStructuresOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'ClosingStructuresCalculationEntityId' INTEGER NOT NULL, + 'RequiredProbability' REAL, + 'RequiredReliability' REAL, + 'Probability' REAL, + 'Reliability' REAL, + 'FactorOfSafety' REAL, + CONSTRAINT 'FK_ClosingStructuresOutputEntity_ClosingStructuresCalculationEntity' FOREIGN KEY ('ClosingStructuresCalculationEntityId') REFERENCES 'ClosingStructuresCalculationEntity' ('ClosingStructuresCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'U_ClosingStructuresCalculationEntity' UNIQUE ('ClosingStructuresCalculationEntityId') +) +; + +CREATE TABLE 'StabilityPointStructureEntity' +( + 'StabilityPointStructureEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'Order' INT (4) NOT NULL, + 'Name' VARCHAR (260), + 'Id' VARCHAR (260), + 'X' REAL, + 'Y' REAL, + 'StructureNormalOrientation' REAL, + 'StorageStructureAreaMean' REAL, + 'StorageStructureAreaCoefficientOfVariation' REAL, + 'AllowedLevelIncreaseStorageMean' REAL, + 'AllowedLevelIncreaseStorageStandardDeviation' REAL, + 'WidthFlowAperturesMean' REAL, + 'WidthFlowAperturesStandardDeviation' REAL, + 'InsideWaterLevelMean' REAL, + 'InsideWaterLevelStandardDeviation' REAL, + 'ThresholdHeightOpenWeirMean' REAL, + 'ThresholdHeightOpenWeirStandardDeviation' REAL, + 'CriticalOvertoppingDischargeMean' REAL, + 'CriticalOvertoppingDischargeCoefficientOfVariation' REAL, + 'FlowWidthAtBottomProtectionMean' REAL, + 'FlowWidthAtBottomProtectionStandardDeviation' REAL, + 'ConstructiveStrengthLinearLoadModelMean' REAL, + 'ConstructiveStrengthLinearLoadModelCoefficientOfVariation' REAL, + 'ConstructiveStrengthQuadraticLoadModelMean' REAL, + 'ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation' REAL, + 'BankWidthMean' REAL, + 'BankWidthStandardDeviation' REAL, + 'InsideWaterLevelFailureConstructionMean' REAL, + 'InsideWaterLevelFailureConstructionStandardDeviation' REAL, + 'EvaluationLevel' REAL, + 'LevelCrestStructureMean' REAL, + 'LevelCrestStructureStandardDeviation' REAL, + 'VerticalDistance' REAL, + 'FailureProbabilityRepairClosure' REAL, + 'FailureCollisionEnergyMean' REAL, + 'FailureCollisionEnergyCoefficientOfVariation' REAL, + 'ShipMassMean' REAL, + 'ShipMassCoefficientOfVariation' REAL, + 'ShipVelocityMean' REAL, + 'ShipVelocityCoefficientOfVariation' REAL, + 'LevellingCount' INT (4) NOT NULL, + 'ProbabilityCollisionSecondaryStructure' REAL, + 'FlowVelocityStructureClosableMean' REAL, + 'StabilityLinearLoadModelMean' REAL, + 'StabilityLinearLoadModelCoefficientOfVariation' REAL, + 'StabilityQuadraticLoadModelMean' REAL, + 'StabilityQuadraticLoadModelCoefficientOfVariation' REAL, + 'AreaFlowAperturesMean' REAL, + 'AreaFlowAperturesStandardDeviation' REAL, + 'InflowModelType' TINYINT (1) NOT NULL, -- Enum: 1 = LowSill, 2 = FloodedCulvert + CONSTRAINT 'FK_StabilityPointStructureEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'StabilityPointStructuresOutputEntity' +( + 'StabilityPointStructuresOutputEntity' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'StabilityPointStructuresCalculationEntityId' INTEGER NOT NULL, + 'RequiredProbability' REAL, + 'RequiredReliability' REAL, + 'Probability' REAL, + 'Reliability' REAL, + 'FactorOfSafety' REAL, + CONSTRAINT 'FK_StabilityPointStructuresOutputEntity_StabilityPointStructuresCalculationEntity' FOREIGN KEY ('StabilityPointStructuresCalculationEntityId') REFERENCES 'StabilityPointStructuresCalculationEntity' ('StabilityPointStructuresCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'U_StabilityPointStructuresCalculationEntity' UNIQUE ('StabilityPointStructuresCalculationEntityId') +) +; + +CREATE TABLE 'HydraulicLocationOutputEntity' +( + 'HydraulicLocationEntityOutputId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'HydraulicLocationEntityId' INTEGER NOT NULL, + 'HydraulicLocationOutputType' TINYINT (1) NOT NULL, -- Enum: 1 = DesignWaterLevel, 2 = WaveHeight + 'Result' REAL, + 'TargetProbability' REAL, + 'TargetReliability' REAL, + 'CalculatedProbability' REAL, + 'CalculatedReliability' REAL, + 'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculatedNotConverged, 3 = CalculatedConverged + CONSTRAINT 'FK_HydraulicLocationOutputEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'U_HydraulicLocationEntityOutputType' UNIQUE ('HydraulicLocationEntityId','HydraulicLocationOutputType') +) +; + +CREATE TABLE 'GrassCoverErosionOutwardsHydraulicLocationOutputEntity' +( + 'GrassCoverErosionOutwardsHydraulicLocationOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'GrassCoverErosionOutwardsHydraulicLocationEntityId' INTEGER NOT NULL, + 'HydraulicLocationOutputType' TINYINT (1) NOT NULL, -- Enum: 1 = DesignWaterLevel, 2 = WaveHeight + 'Result' REAL, + 'TargetProbability' REAL, + 'TargetReliability' REAL, + 'CalculatedProbability' REAL, + 'CalculatedReliability' REAL, + 'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculatedNotConverged, 3 = CalculatedConverged + CONSTRAINT 'FK_GrassCoverErosionOutwardsHydraulicLocationOutputEntity_GrassCoverErosionOutwardsHydraulicLocationEntity' FOREIGN KEY ('GrassCoverErosionOutwardsHydraulicLocationEntityId') REFERENCES 'GrassCoverErosionOutwardsHydraulicLocationEntity' ('GrassCoverErosionOutwardsHydraulicLocationEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'U_HydraulicLocationOutputType' UNIQUE ('GrassCoverErosionOutwardsHydraulicLocationEntityId','HydraulicLocationOutputType') +) +; + +CREATE TABLE 'DuneLocationEntity' +( + 'DuneLocationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER NOT NULL, + 'LocationId' INTEGER NOT NULL, + 'Name' VARCHAR (260) NOT NULL, + 'LocationX' REAL, + 'LocationY' REAL, + 'CoastalAreaId' INT (4) NOT NULL, + 'Offset' REAL, + 'Orientation' REAL, + 'D50' REAL, + 'Order' INT (4) NOT NULL, + CONSTRAINT 'FK_DuneLocationEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'DuneLocationOutputEntity' +( + 'DuneLocationOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'DuneLocationEntityId' INTEGER NOT NULL, + 'WaterLevel' REAL, + 'WaveHeight' REAL, + 'WavePeriod' REAL, + 'TargetProbability' REAL, + 'TargetReliability' REAL, + 'CalculatedProbability' REAL, + 'CalculatedReliability' REAL, + 'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculatedNotConverged, 3 = CalculatedConverged + CONSTRAINT 'FK_DuneLocationOutputEntity_DuneLocationEntity' FOREIGN KEY ('DuneLocationEntityId') REFERENCES 'DuneLocationEntity' ('DuneLocationEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +/* Create Indexes and Triggers */ + +CREATE INDEX 'IXFK_GrassCoverErosionInwardsDikeHeightOutputEntity_GrassCoverErosionInwardsOutputEntity' + ON 'GrassCoverErosionInwardsDikeHeightOutputEntity' ('GrassCoverErosionInwardsOutputEntityId' ASC) +; + +CREATE INDEX 'IXFK_StabilityPointStructuresCalculationEntity_CalculationGroupEntity' + ON 'StabilityPointStructuresCalculationEntity' ('CalculationGroupEntityId' ASC) +; + +CREATE INDEX 'IXFK_StabilityPointStructuresCalculationEntity_ForeshoreProfileEntity' + ON 'StabilityPointStructuresCalculationEntity' ('ForeshoreProfileEntityId' ASC) +; + +CREATE INDEX 'IXFK_StabilityPointStructuresCalculationEntity_HydraulicLocationEntity' + ON 'StabilityPointStructuresCalculationEntity' ('HydraulicLocationEntityId' ASC) +; + +CREATE INDEX 'IXFK_StabilityPointStructuresCalculationEntity_StabilityPointStructureEntity' + ON 'StabilityPointStructuresCalculationEntity' ('StabilityPointStructureEntityId' ASC) +; + +CREATE INDEX 'IXFK_AssessmentSectionEntity_ProjectEntity' + ON 'AssessmentSectionEntity' ('ProjectEntityId' ASC) +; + +CREATE INDEX 'IXFK_FailureMechanismEntity_AssessmentSectionEntity' + ON 'FailureMechanismEntity' ('AssessmentSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_FailureMechanismEntity_CalculationGroupEntity' + ON 'FailureMechanismEntity' ('CalculationGroupEntityId' ASC) +; + +CREATE INDEX 'IXFK_FailureMechanismSectionEntity_FailureMechanismEntity' + ON 'FailureMechanismSectionEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_PipingFailureMechanismMetaEntity_FailureMechanismEntity' + ON 'PipingFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_StrengthStabilityPointConstructionFailureMechanismMetaEntity_FailureMechanismEntity' + ON 'StabilityPointStructuresFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_ClosingStructuresFailureMechanismMetaEntity_FailureMechanismEntity' + ON 'ClosingStructuresFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_DuneErosionFailureMechanismMetaEntity_FailureMechanismEntity' + ON 'DuneErosionFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_CalculationGroupEntity_CalculationGroupEntity' + ON 'CalculationGroupEntity' ('ParentCalculationGroupEntityId' ASC) +; + +CREATE INDEX 'IXFK_HeightStructuresFailureMechanismMetaEntity_FailureMechanismEntity' + ON 'HeightStructuresFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_HydraulicLocationEntity_AssessmentSectionEntity' + ON 'HydraulicLocationEntity' ('AssessmentSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_PipingCalculationEntity_StochasticSoilProfileEntity' + ON 'PipingCalculationEntity' ('StochasticSoilProfileEntityId' ASC) +; + +CREATE INDEX 'IXFK_PipingCalculationEntity_SurfaceLineEntity' + ON 'PipingCalculationEntity' ('SurfaceLineEntityId' ASC) +; + +CREATE INDEX 'IXFK_PipingCalculationEntity_HydraulicLocationEntity' + ON 'PipingCalculationEntity' ('HydraulicLocationEntityId' ASC) +; + +CREATE INDEX 'IXFK_PipingCalculationEntity_CalculationGroupEntity' + ON 'PipingCalculationEntity' ('CalculationGroupEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionInwardsFailureMechanismMetaEntity_FailureMechanismEntity' + ON 'GrassCoverErosionInwardsFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionInwardsCalculationEntity_CalculationGroupEntity' + ON 'GrassCoverErosionInwardsCalculationEntity' ('CalculationGroupEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionInwardsCalculationEntity_DikeProfileEntity' + ON 'GrassCoverErosionInwardsCalculationEntity' ('DikeProfileEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionInwardsCalculationEntity_HydraulicLocationEntity' + ON 'GrassCoverErosionInwardsCalculationEntity' ('HydraulicLocationEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_FailureMechanismEntity' + ON 'GrassCoverErosionOutwardsFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_StochasticSoilProfileEntity_SoilProfileEntity' + ON 'StochasticSoilProfileEntity' ('SoilProfileEntityId' ASC) +; + +CREATE INDEX 'IXFK_StochasticSoilProfileEntity_StochasticSoilModelEntity' + ON 'StochasticSoilProfileEntity' ('StochasticSoilModelEntityId' ASC) +; + +CREATE INDEX 'IXFK_StochasticSoilModelEntity_FailureMechanismEntity' + ON 'StochasticSoilModelEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_SurfaceLineEntity_FailureMechanismEntity' + ON 'SurfaceLineEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_SurfaceLinePointEntity_SurfaceLineEntity' + ON 'CharacteristicPointEntity' ('SurfaceLineEntityId' ASC) +; + +CREATE INDEX 'IXFK_PipingCalculationOutputEntity_PipingCalculationEntity' + ON 'PipingCalculationOutputEntity' ('PipingCalculationEntityId' ASC) +; + +CREATE INDEX 'IXFK_PipingSemiProbabilisticOutputEntity_PipingCalculationEntity' + ON 'PipingSemiProbabilisticOutputEntity' ('PipingCalculationEntityId' ASC) +; + +CREATE INDEX 'IXFK_PipingSectionResultEntity_FailureMechanismSectionEntity' + ON 'PipingSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionInwardsSectionResultEntity_FailureMechanismSectionEntity' + ON 'GrassCoverErosionInwardsSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionInwardsSectionResultEntity_GrassCoverErosionInwardsCalculationEntity' + ON 'GrassCoverErosionInwardsSectionResultEntity' ('GrassCoverErosionInwardsCalculationEntityId' ASC) +; + +CREATE INDEX 'IXFK_HeightStructuresSectionResultEntity_FailureMechanismSectionEntity' + ON 'HeightStructuresSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_HeightStructuresSectionResultEntity_HeightStructuresCalculationEntity' + ON 'HeightStructuresSectionResultEntity' ('HeightStructuresCalculationEntityId' ASC) +; + +CREATE INDEX 'IXFK_StrengthStabilityLengthwiseConstructionSectionResultEntity_FailureMechanismSectionEntity' + ON 'StrengthStabilityLengthwiseConstructionSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_TechnicalInnovationSectionResultEntity_FailureMechanismSectionEntity' + ON 'TechnicalInnovationSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_WaterPressureAsphaltCoverSectionResultEntity_FailureMechanismSectionEntity' + ON 'WaterPressureAsphaltCoverSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_ClosingStructuresSectionResultEntity_ClosingStructuresCalculationEntity' + ON 'ClosingStructuresSectionResultEntity' ('ClosingStructuresCalculationEntityId' ASC) +; + +CREATE INDEX 'IXFK_ClosingStructuresSectionResultEntity_FailureMechanismSectionEntity' + ON 'ClosingStructuresSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionOutwardsSectionResultEntity_FailureMechanismSectionEntity' + ON 'GrassCoverErosionOutwardsSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverSlipOffInwardsSectionResultEntity_FailureMechanismSectionEntity' + ON 'GrassCoverSlipOffInwardsSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverSlipOffOutwardsSectionResultEntity_FailureMechanismSectionEntity' + ON 'GrassCoverSlipOffOutwardsSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_MacrostabilityInwardsSectionResultEntity_FailureMechanismSectionEntity' + ON 'MacrostabilityInwardsSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_MacrostabilityOutwardsSectionResultEntity_FailureMechanismSectionEntity' + ON 'MacrostabilityOutwardsSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_WaveImpactAsphaltCoverSectionResultEntity_FailureMechanismSectionEntity' + ON 'WaveImpactAsphaltCoverSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_MicrostabilitySectionResultEntity_FailureMechanismSectionEntity' + ON 'MicrostabilitySectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_PipingStructureSectionResultEntity_FailureMechanismSectionEntity' + ON 'PipingStructureSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_DuneErosionSectionResultEntity_FailureMechanismSectionEntity' + ON 'DuneErosionSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_StabilityStoneCoverSectionResultEntity_FailureMechanismSectionEntity' + ON 'StabilityStoneCoverSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_StabilityPointStructuresSectionResultEntity_FailureMechanismSectionEntity' + ON 'StabilityPointStructuresSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_StabilityPointStructuresSectionResultEntity_StabilityPointStructuresCalculationEntity' + ON 'StabilityPointStructuresSectionResultEntity' ('StabilityPointStructuresCalculationEntityId' ASC) +; + +CREATE INDEX 'IXFK_DikeProfileEntity_FailureMechanismEntity' + ON 'DikeProfileEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionInwardsOutputEntity_GrassCoverErosionInwardsCalculationEntity' + ON 'GrassCoverErosionInwardsOutputEntity' ('GrassCoverErosionInwardsCalculationEntityId' ASC) +; + +CREATE INDEX 'IXFK_ForeshoreProfileEntity_FailureMechanismEntity' + ON 'ForeshoreProfileEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_StabilityStoneCoverWaveConditionsCalculationEntity_CalculationGroupEntity' + ON 'StabilityStoneCoverWaveConditionsCalculationEntity' ('CalculationGroupEntityId' ASC) +; + +CREATE INDEX 'IXFK_StabilityStoneCoverWaveConditionsCalculationEntity_ForeshoreProfileEntity' + ON 'StabilityStoneCoverWaveConditionsCalculationEntity' ('ForeshoreProfileEntityId' ASC) +; + +CREATE INDEX 'IXFK_StabilityStoneCoverWaveConditionsCalculationEntity_HydraulicLocationEntity' + ON 'StabilityStoneCoverWaveConditionsCalculationEntity' ('HydraulicLocationEntityId' ASC) +; + +CREATE INDEX 'IXFK_StabilityStoneCoverWaveConditionsOutputEntity_StabilityStoneCoverWaveConditionsCalculationEntity' + ON 'StabilityStoneCoverWaveConditionsOutputEntity' ('StabilityStoneCoverWaveConditionsCalculationEntityId' ASC) +; + +CREATE INDEX 'IXFK_WaveImpactAsphaltCoverWaveConditionsCalculationEntity_CalculationGroupEntity' + ON 'WaveImpactAsphaltCoverWaveConditionsCalculationEntity' ('CalculationGroupEntityId' ASC) +; + +CREATE INDEX 'IXFK_WaveImpactAsphaltCoverWaveConditionsCalculationEntity_ForeshoreProfileEntity' + ON 'WaveImpactAsphaltCoverWaveConditionsCalculationEntity' ('ForeshoreProfileEntityId' ASC) +; + +CREATE INDEX 'IXFK_WaveImpactAsphaltCoverWaveConditionsCalculationEntity_HydraulicLocationEntity' + ON 'WaveImpactAsphaltCoverWaveConditionsCalculationEntity' ('HydraulicLocationEntityId' ASC) +; + +CREATE INDEX 'IXFK_WaveImpactAsphaltCoverWaveConditionsOutputEntity_WaveImpactAsphaltCoverWaveConditionsCalculationEntity' + ON 'WaveImpactAsphaltCoverWaveConditionsOutputEntity' ('WaveImpactAsphaltCoverWaveConditionsCalculationEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionOutwardsWaveConditionsCalculationEntity_CalculationGroupEntity' + ON 'GrassCoverErosionOutwardsWaveConditionsCalculationEntity' ('CalculationGroupEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionOutwardsWaveConditionsCalculationEntity_ForeshoreProfileEntity' + ON 'GrassCoverErosionOutwardsWaveConditionsCalculationEntity' ('ForeshoreProfileEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionOutwardsWaveConditionsCalculationEntity_GrassCoverErosionOutwardsHydraulicLocationEntity' + ON 'GrassCoverErosionOutwardsWaveConditionsCalculationEntity' ('GrassCoverErosionOutwardsHydraulicLocationEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionOutwardsHydraulicLocationEntity_FailureMechanismEntity' + ON 'GrassCoverErosionOutwardsHydraulicLocationEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionOutwardsWaveConditionsOutputEntity_GrassCoverErosionOutwardsWaveConditionsCalculationEntity' + ON 'GrassCoverErosionOutwardsWaveConditionsOutputEntity' ('GrassCoverErosionOutwardsWaveConditionsCalculationEntityId' ASC) +; + +CREATE INDEX 'IXFK_HeightStructuresOutputEntity_HeightStructuresCalculationEntity' + ON 'HeightStructuresOutputEntity' ('HeightStructuresCalculationEntityId' ASC) +; + +CREATE INDEX 'IXFK_HeightStructure_FailureMechanismEntity' + ON 'HeightStructureEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_HeightStructuresCalculationEntity_CalculationGroupEntity' + ON 'HeightStructuresCalculationEntity' ('CalculationGroupEntityId' ASC) +; + +CREATE INDEX 'IXFK_HeightStructuresCalculationEntity_ForeshoreProfileEntity' + ON 'HeightStructuresCalculationEntity' ('ForeshoreProfileEntityId' ASC) +; + +CREATE INDEX 'IXFK_HeightStructuresCalculationEntity_HeightStructureEntity' + ON 'HeightStructuresCalculationEntity' ('HeightStructureEntityId' ASC) +; + +CREATE INDEX 'IXFK_HeightStructuresCalculationEntity_HydraulicLocationEntity' + ON 'HeightStructuresCalculationEntity' ('HydraulicLocationEntityId' ASC) +; + +CREATE INDEX 'IXFK_ClosingStructureEntity_FailureMechanismEntity' + ON 'ClosingStructureEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_ClosingStructuresCalculationEntity_CalculationGroupEntity' + ON 'ClosingStructuresCalculationEntity' ('CalculationGroupEntityId' ASC) +; + +CREATE INDEX 'IXFK_ClosingStructuresCalculationEntity_ClosingStructureEntity' + ON 'ClosingStructuresCalculationEntity' ('ClosingStructureEntityId' ASC) +; + +CREATE INDEX 'IXFK_ClosingStructuresCalculationEntity_ForeshoreProfileEntity' + ON 'ClosingStructuresCalculationEntity' ('ForeshoreProfileEntityId' ASC) +; + +CREATE INDEX 'IXFK_ClosingStructuresCalculationEntity_HydraulicLocationEntity' + ON 'ClosingStructuresCalculationEntity' ('HydraulicLocationEntityId' ASC) +; + +CREATE INDEX 'IXFK_ClosingStructuresOutputEntity_ClosingStructuresCalculationEntity' + ON 'ClosingStructuresOutputEntity' ('ClosingStructuresCalculationEntityId' ASC) +; + +CREATE INDEX 'IXFK_StabilityPointStructureEntity_FailureMechanismEntity' + ON 'StabilityPointStructureEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_StabilityPointStructuresOutputEntity_StabilityPointStructuresCalculationEntity' + ON 'StabilityPointStructuresOutputEntity' ('StabilityPointStructuresCalculationEntityId' ASC) +; + +CREATE INDEX 'IXFK_HydraulicLocationOutputEntity_HydraulicLocationEntity' + ON 'HydraulicLocationOutputEntity' ('HydraulicLocationEntityId' ASC) +; + +CREATE INDEX 'IXFK_GrassCoverErosionOutwardsHydraulicLocationOutputEntity_GrassCoverErosionOutwardsHydraulicLocationEntity' + ON 'GrassCoverErosionOutwardsHydraulicLocationOutputEntity' ('GrassCoverErosionOutwardsHydraulicLocationEntityId' ASC) +; + +CREATE INDEX 'IXFK_DuneLocationEntity_FailureMechanismEntity' + ON 'DuneLocationEntity' ('FailureMechanismEntityId' ASC) +; + +CREATE INDEX 'IXFK_DuneLocationOutputEntity_DuneLocationEntity' + ON 'DuneLocationOutputEntity' ('DuneLocationEntityId' ASC) +; Index: Migration/Scripts/src/Migration.Scripts.Data/Resources/Migration_4_17.1.sql =================================================================== diff -u --- Migration/Scripts/src/Migration.Scripts.Data/Resources/Migration_4_17.1.sql (revision 0) +++ Migration/Scripts/src/Migration.Scripts.Data/Resources/Migration_4_17.1.sql (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -0,0 +1,48 @@ +ATTACH [{0}] AS SOURCEPROJECT; + +INSERT INTO VersionEntity ( + [VersionId], + [Version], + [Timestamp], + [FingerPrint]) +SELECT + [VersionId], + "17.1", + [Timestamp], + [FingerPrint] +FROM [SOURCEPROJECT].VersionEntity; + +INSERT INTO ProjectEntity +SELECT * FROM [SOURCEPROJECT].ProjectEntity; + +INSERT INTO AssessmentSectionEntity ( + [AssessmentSectionEntityId], + [ProjectEntityId], + [Id], + [Name], + [Comments], + [Norm], + [HydraulicDatabaseVersion], + [HydraulicDatabaseLocation], + [Composition], + [ReferenceLinePointXml], + [Order]) +SELECT + [AssessmentSectionEntityId], + [ProjectEntityId], + [Id], + [Name], + [Comments], + [Norm], + [HydraulicDatabaseVersion], + [HydraulicDatabaseLocation], + [Composition], + [ReferenceLinePointXml], + [Order] +FROM [SOURCEPROJECT].AssessmentSectionEntity; + +INSERT INTO HydraulicLocationEntity +SELECT * FROM [SOURCEPROJECT].HydraulicLocationEntity; + +INSERT INTO HydraulicLocationOutputEntity +SELECT * FROM [SOURCEPROJECT].HydraulicLocationOutputEntity; \ No newline at end of file Index: Migration/Scripts/src/Migration.Scripts.Data/RingtoetsDatabaseQueryBuilder.cs =================================================================== diff -u --- Migration/Scripts/src/Migration.Scripts.Data/RingtoetsDatabaseQueryBuilder.cs (revision 0) +++ Migration/Scripts/src/Migration.Scripts.Data/RingtoetsDatabaseQueryBuilder.cs (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -0,0 +1,41 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Migration.Scripts.Data +{ + /// + /// Defines queries to execute on a Ringtoets database. + /// + public static class RingtoetsDatabaseQueryBuilder + { + /// + /// Returns the query to get the version from the Ringtoets database. + /// + /// The query to get the version from the Ringtoets database. + public static string GetVersionQuery() + { + return $"SELECT {VersionTableDefinitions.Version} " + + $"FROM {VersionTableDefinitions.TableName} " + + $"Order by {VersionTableDefinitions.Timestamp} DESC " + + "LIMIT 1"; + } + } +} \ No newline at end of file Index: Migration/Scripts/src/Migration.Scripts.Data/VersionTableDefinitions.cs =================================================================== diff -u --- Migration/Scripts/src/Migration.Scripts.Data/VersionTableDefinitions.cs (revision 0) +++ Migration/Scripts/src/Migration.Scripts.Data/VersionTableDefinitions.cs (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -0,0 +1,33 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Migration.Scripts.Data +{ + /// + /// Defines the table and column names of the table 'VersionEntity' in the Ringtoets database. + /// + public static class VersionTableDefinitions + { + public const string TableName = "VersionEntity"; + public const string Version = "Version"; + public const string Timestamp = "Timestamp"; + } +} \ No newline at end of file Index: Migration/Scripts/test/Migration.Scripts.Data.Test/Migration.Scripts.Data.Test.csproj =================================================================== diff -u -r535a93fde55619f58673f758edae5dc7c1b9df51 -r6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b --- Migration/Scripts/test/Migration.Scripts.Data.Test/Migration.Scripts.Data.Test.csproj (.../Migration.Scripts.Data.Test.csproj) (revision 535a93fde55619f58673f758edae5dc7c1b9df51) +++ Migration/Scripts/test/Migration.Scripts.Data.Test/Migration.Scripts.Data.Test.csproj (.../Migration.Scripts.Data.Test.csproj) (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -1,6 +1,5 @@  - Debug x86 Index: Ringtoets.sln =================================================================== diff -u -r535a93fde55619f58673f758edae5dc7c1b9df51 -r6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b --- Ringtoets.sln (.../Ringtoets.sln) (revision 535a93fde55619f58673f758edae5dc7c1b9df51) +++ Ringtoets.sln (.../Ringtoets.sln) (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b) @@ -1307,8 +1307,14 @@ EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Migration.Scripts.Data", "Migration\Scripts\src\Migration.Scripts.Data\Migration.Scripts.Data.csproj", "{D08DB9E2-6861-44C8-A725-71A70274CC77}" + ProjectSection(ProjectDependencies) = postProject + {C90B77DA-E421-43CC-B82E-529651BC21AC} = {C90B77DA-E421-43CC-B82E-529651BC21AC} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Migration.Scripts.Data.Test", "Migration\Scripts\test\Migration.Scripts.Data.Test\Migration.Scripts.Data.Test.csproj", "{A60F35B7-7538-4516-94BB-09B19FE22FAA}" + ProjectSection(ProjectDependencies) = postProject + {C90B77DA-E421-43CC-B82E-529651BC21AC} = {C90B77DA-E421-43CC-B82E-529651BC21AC} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution