Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added run before up folder #51

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion product/roundhouse.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}\".",
Expand Down Expand Up @@ -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 " +
Expand Down
2 changes: 2 additions & 0 deletions product/roundhouse.tasks/Roundhouse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
1 change: 1 addition & 0 deletions product/roundhouse/consoles/DefaultConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
3 changes: 3 additions & 0 deletions product/roundhouse/folders/DefaultKnownFolders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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; }
Expand Down
1 change: 1 addition & 0 deletions product/roundhouse/folders/KnownFolders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions product/roundhouse/infrastructure/ApplicationParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions product/roundhouse/runners/RoundhouseMigrationRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down