Index: Migration/Scripts/src/Migration.Scripts.Data/UpgradeScript.cs
===================================================================
diff -u -r07ab02003751f717e8534ff7392cb915efcdc3b8 -r58d375a1c6b920e8597eae37dde622fda6a456ee
--- Migration/Scripts/src/Migration.Scripts.Data/UpgradeScript.cs (.../UpgradeScript.cs) (revision 07ab02003751f717e8534ff7392cb915efcdc3b8)
+++ Migration/Scripts/src/Migration.Scripts.Data/UpgradeScript.cs (.../UpgradeScript.cs) (revision 58d375a1c6b920e8597eae37dde622fda6a456ee)
@@ -20,32 +20,29 @@
// All rights reserved.
using System;
-using System.Data.SQLite;
+using Migration.Scripts.Data.Exceptions;
namespace Migration.Scripts.Data
{
///
- /// Class that provides methods for the upgrading a for a specific version.
+ /// Class that provides methods for the upgrading a for a specific version.
///
- public class UpgradeScript
+ public abstract class UpgradeScript
{
private readonly string fromVersion;
private readonly string toVersion;
- private readonly string upgradeQuery;
///
/// Creates a new instance of the class.
///
- /// The source version was designed for.
- /// The target version was designed for.
- /// The SQL query to upgrade from to .
+ /// The source version.
+ /// The target version.
/// Thrown when:
///
/// - is empty or null,
/// - is empty or null,
- /// - is empty, null, or consists out of only whitespace characters.
///
- public UpgradeScript(string fromVersion, string toVersion, string query)
+ protected UpgradeScript(string fromVersion, string toVersion)
{
if (string.IsNullOrEmpty(fromVersion))
{
@@ -55,13 +52,9 @@
{
throw new ArgumentException(@"ToVersion must have a value.", nameof(toVersion));
}
- if (string.IsNullOrWhiteSpace(query))
- {
- throw new ArgumentException(@"Query must have a value.", nameof(query));
- }
+
this.fromVersion = fromVersion;
this.toVersion = toVersion;
- upgradeQuery = query;
}
///
@@ -92,7 +85,7 @@
/// - is null,
/// - is null.
///
- /// Thrown when executing query failed.
+ /// Thrown when executing query failed.
public void Upgrade(IVersionedFile source, IVersionedFile target)
{
if (source == null)
@@ -103,13 +96,9 @@
{
throw new ArgumentNullException(nameof(target));
}
- var query = string.Format(upgradeQuery, source.Location);
-
- using (var databaseFile = new RingtoetsDatabaseFile(target.Location))
- {
- databaseFile.OpenDatabaseConnection();
- databaseFile.ExecuteMigration(query);
- }
+ PerformUpgrade(source, target);
}
+
+ protected abstract void PerformUpgrade(IVersionedFile source, IVersionedFile target);
}
}
\ No newline at end of file