Skip to content

Commit

Permalink
https://github.com/chucknorris/roundhouse/pull/51
Browse files Browse the repository at this point in the history
  • Loading branch information
ferventcoder committed Sep 7, 2012
1 parent 5d8dacf commit 644020f
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 4 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public ISessionFactory build_session_factory(Action<Configuration> additional_fu
}
catch (Exception ex)
{
Log.bound_to(this).log_a_warning_event_containing("Had an error building session factory from merged, attempting unmerged. The error:{0}{1}",System.Environment.NewLine,ex.ToString());
// Changed from warning to debug. I may not be using session factory and this warning just adds noise.
Log.bound_to(this).log_a_debug_event_containing("Had an error building session factory from merged, attempting unmerged. The error:{0}{1}",System.Environment.NewLine,ex.ToString());
return build_session_factory(func_dictionary[configuration_holder.DatabaseType](), DefaultAssemblyLoader.load_assembly(assembly_name),
top_namespace, additional_function);
}
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

0 comments on commit 644020f

Please sign in to comment.