diff --git a/product/roundhouse.console/Program.cs b/product/roundhouse.console/Program.cs index 9bd79c4f..9a01a754 100644 --- a/product/roundhouse.console/Program.cs +++ b/product/roundhouse.console/Program.cs @@ -143,6 +143,11 @@ private static void parse_arguments_and_set_up_configuration(ConfigurationProper "RunAfterCreateDatabaseFolderName - The name of the folder where you will keep scripts that ONLY run after a database is created. Will recurse through subfolders. Defaults to \"{0}\".", ApplicationParameters.default_run_after_create_database_folder_name), option => configuration.RunAfterCreateDatabaseFolderName = option) + .Add("rb=|runbefore=|runbeforeupfolder=|runbeforeupfoldername=", + string.Format( + "RunBeforeUpFolderName - The name of the folder where you keep scripts that you want to run before your update scripts. Will recurse through subfolders. Defaults to \"{0}\".", + ApplicationParameters.default_run_before_up_folder_name), + option => configuration.RunBeforeUpFolderName = option) .Add("u=|up=|upfolder=|upfoldername=", string.Format( "UpFolderName - The name of the folder where you keep your update scripts. Will recurse through subfolders. Defaults to \"{0}\".", @@ -315,7 +320,8 @@ private static void parse_arguments_and_set_up_configuration(ConfigurationProper "/c[onnection]s[tring]a[dministration] VALUE " + "/c[ommand]t[imeout] VALUE /c[ommand]t[imeout]a[dmin] VALUE " + "/r[epositorypath] VALUE /v[ersion]f[ile] VALUE /v[ersion]x[path] VALUE " + - "/a[lter]d[atabasefoldername] /r[un]a[fter]c[reate]d[atabasefoldername] VALUE VALUE /u[pfoldername] VALUE /do[wnfoldername] VALUE " + + "/a[lter]d[atabasefoldername] /r[un]a[fter]c[reate]d[atabasefoldername] VALUE VALUE " + + "/r[un]b[eforeupfoldername] VALUE /u[pfoldername] VALUE /do[wnfoldername] VALUE " + "/r[un]f[irstafterupdatefoldername] VALUE /fu[nctionsfoldername] VALUE /v[ie]w[sfoldername] VALUE " + "/sp[rocsfoldername] VALUE /i[nde]x[foldername] VALUE /p[ermissionsfoldername] VALUE " + "/sc[hemaname] VALUE /v[ersion]t[ablename] VALUE /s[cripts]r[un]t[ablename] VALUE /s[cripts]r[un]e[rrors]t[ablename] VALUE " + diff --git a/product/roundhouse.tasks/Roundhouse.cs b/product/roundhouse.tasks/Roundhouse.cs index ee01ebc1..70c4a979 100644 --- a/product/roundhouse.tasks/Roundhouse.cs +++ b/product/roundhouse.tasks/Roundhouse.cs @@ -61,6 +61,8 @@ bool ITask.Execute() public string RunAfterCreateDatabaseFolderName { get; set; } + public string RunBeforeUpFolderName { get; set; } + public string UpFolderName { get; set; } public string DownFolderName { get; set; } diff --git a/product/roundhouse/consoles/DefaultConfiguration.cs b/product/roundhouse/consoles/DefaultConfiguration.cs index ea3f92ea..38f1fb22 100644 --- a/product/roundhouse/consoles/DefaultConfiguration.cs +++ b/product/roundhouse/consoles/DefaultConfiguration.cs @@ -20,6 +20,7 @@ public sealed class DefaultConfiguration : ConfigurationPropertyHolder public string VersionXPath { get; set; } public string AlterDatabaseFolderName { get; set; } public string RunAfterCreateDatabaseFolderName { get; set; } + public string RunBeforeUpFolderName { get; set; } public string UpFolderName { get; set; } public string DownFolderName { get; set; } public string RunFirstAfterUpFolderName { get; set; } diff --git a/product/roundhouse/folders/DefaultKnownFolders.cs b/product/roundhouse/folders/DefaultKnownFolders.cs index e43ce44f..a64cd192 100644 --- a/product/roundhouse/folders/DefaultKnownFolders.cs +++ b/product/roundhouse/folders/DefaultKnownFolders.cs @@ -5,6 +5,7 @@ public sealed class DefaultKnownFolders : KnownFolders public DefaultKnownFolders( MigrationsFolder alter_database, MigrationsFolder run_after_create_database, + MigrationsFolder run_before_up, MigrationsFolder up, MigrationsFolder down, MigrationsFolder run_first_after_up, @@ -19,6 +20,7 @@ Folder change_drop { this.alter_database = alter_database; this.run_after_create_database = run_after_create_database; + this.run_before_up = run_before_up; this.up = up; this.down = down; this.run_first_after_up = run_first_after_up; @@ -33,6 +35,7 @@ Folder change_drop public MigrationsFolder alter_database { get; private set; } public MigrationsFolder run_after_create_database { get; private set; } + public MigrationsFolder run_before_up { get; private set; } public MigrationsFolder up { get; private set; } public MigrationsFolder down { get; private set; } public MigrationsFolder run_first_after_up { get; private set; } diff --git a/product/roundhouse/folders/KnownFolders.cs b/product/roundhouse/folders/KnownFolders.cs index 83bbfb30..b81c5988 100644 --- a/product/roundhouse/folders/KnownFolders.cs +++ b/product/roundhouse/folders/KnownFolders.cs @@ -4,6 +4,7 @@ public interface KnownFolders { MigrationsFolder alter_database { get; } MigrationsFolder run_after_create_database { get; } + MigrationsFolder run_before_up { get; } MigrationsFolder up { get; } MigrationsFolder down { get; } MigrationsFolder run_first_after_up { get; } diff --git a/product/roundhouse/infrastructure.app/ApplicationConfiguraton.cs b/product/roundhouse/infrastructure.app/ApplicationConfiguraton.cs index 291200c4..5631471f 100644 --- a/product/roundhouse/infrastructure.app/ApplicationConfiguraton.cs +++ b/product/roundhouse/infrastructure.app/ApplicationConfiguraton.cs @@ -52,6 +52,10 @@ public static void set_defaults_if_properties_are_not_set(ConfigurationPropertyH { configuration_property_holder.RunAfterCreateDatabaseFolderName = ApplicationParameters.default_run_after_create_database_folder_name; } + if (string.IsNullOrEmpty(configuration_property_holder.RunBeforeUpFolderName)) + { + configuration_property_holder.RunBeforeUpFolderName = ApplicationParameters.default_run_before_up_folder_name; + } if (string.IsNullOrEmpty(configuration_property_holder.UpFolderName)) { configuration_property_holder.UpFolderName = ApplicationParameters.default_up_folder_name; diff --git a/product/roundhouse/infrastructure.app/ConfigurationPropertyHolder.cs b/product/roundhouse/infrastructure.app/ConfigurationPropertyHolder.cs index 21704591..cfc65ce5 100644 --- a/product/roundhouse/infrastructure.app/ConfigurationPropertyHolder.cs +++ b/product/roundhouse/infrastructure.app/ConfigurationPropertyHolder.cs @@ -20,6 +20,7 @@ public interface ConfigurationPropertyHolder string VersionXPath { get; set; } string AlterDatabaseFolderName { get; set; } string RunAfterCreateDatabaseFolderName { get; set; } + string RunBeforeUpFolderName { get; set; } string UpFolderName { get; set; } string DownFolderName { get; set; } string RunFirstAfterUpFolderName { get; set; } diff --git a/product/roundhouse/infrastructure.app/builders/KnownFoldersBuilder.cs b/product/roundhouse/infrastructure.app/builders/KnownFoldersBuilder.cs index 754407e5..c452c374 100644 --- a/product/roundhouse/infrastructure.app/builders/KnownFoldersBuilder.cs +++ b/product/roundhouse/infrastructure.app/builders/KnownFoldersBuilder.cs @@ -10,7 +10,8 @@ public static KnownFolders build(FileSystemAccess file_system, ConfigurationProp { MigrationsFolder alter_database_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.AlterDatabaseFolderName, false, false, "AlterDatabase"); MigrationsFolder run_after_create_database_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.RunAfterCreateDatabaseFolderName, true, false, "Run After Create Database"); - MigrationsFolder up_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.UpFolderName, true, false, "Update"); + MigrationsFolder run_before_up_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.RunBeforeUpFolderName, false, false, "Run Before Update"); + MigrationsFolder up_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.UpFolderName, true, false, "Update"); MigrationsFolder down_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.DownFolderName, true, false, "Down Folder - Nothing to see here. Move along."); MigrationsFolder run_first_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.RunFirstAfterUpFolderName, false, false, "Run First After Update"); MigrationsFolder functions_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.FunctionsFolderName, false, false, "Function"); @@ -27,7 +28,7 @@ public static KnownFolders build(FileSystemAccess file_system, ConfigurationProp remove_paths_from(configuration_property_holder.ServerName,file_system)), get_run_date_time_string()); - return new DefaultKnownFolders(alter_database_folder, run_after_create_database_folder, up_folder, down_folder, run_first_folder, functions_folder, views_folder, sprocs_folder, indexes_folder, runAfterOtherAnyTimeScripts_folder, permissions_folder, change_drop_folder); + return new DefaultKnownFolders(alter_database_folder, run_after_create_database_folder, run_before_up_folder, up_folder, down_folder, run_first_folder, functions_folder, views_folder, sprocs_folder, indexes_folder, runAfterOtherAnyTimeScripts_folder, permissions_folder, change_drop_folder); } private static string combine_items_into_one_path(FileSystemAccess file_system, params string[] paths) diff --git a/product/roundhouse/infrastructure/ApplicationParameters.cs b/product/roundhouse/infrastructure/ApplicationParameters.cs index fb433c14..0a8e2a63 100644 --- a/product/roundhouse/infrastructure/ApplicationParameters.cs +++ b/product/roundhouse/infrastructure/ApplicationParameters.cs @@ -12,6 +12,7 @@ public static class ApplicationParameters // defaults public static readonly string default_alter_database_folder_name = "alterDatabase"; public static readonly string default_run_after_create_database_folder_name = "runAfterCreateDatabase"; + public static readonly string default_run_before_up_folder_name = "runBeforeUp"; public static readonly string default_up_folder_name = "up"; public static readonly string default_down_folder_name = "down"; public static readonly string default_run_first_after_up_folder_name = "runFirstAfterUp"; diff --git a/product/roundhouse/runners/RoundhouseMigrationRunner.cs b/product/roundhouse/runners/RoundhouseMigrationRunner.cs index 62e8a412..abb76207 100644 --- a/product/roundhouse/runners/RoundhouseMigrationRunner.cs +++ b/product/roundhouse/runners/RoundhouseMigrationRunner.cs @@ -140,6 +140,7 @@ public void run() log_and_traverse(known_folders.run_after_create_database, version_id, new_version, ConnectionType.Default); } + log_and_traverse(known_folders.run_before_up, version_id, new_version, ConnectionType.Default); log_and_traverse(known_folders.up, version_id, new_version, ConnectionType.Default); //int last_errors = -1;