Skip to content

Commit

Permalink
A folder that runs after the other anytime scripts folders have run h…
Browse files Browse the repository at this point in the history
…as been added. Changes from chucknorris/roundhouse#1
  • Loading branch information
ferventcoder committed May 27, 2011
1 parent 9681c5d commit 59b4732
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 46 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Simple script. Can actually call sprocs defined elsewhere because this is run after all of the other anytime scripts
--drop five items prior to this.
-- just remember, this is still an anytime kind of place, so you make a change, it reruns the file.
INSERT INTO dbo.SampleItems (name, firstname, lastname) VALUES ('bob1', 'bob1', 'bubba1')
INSERT INTO dbo.SampleItems (name, firstname, lastname) VALUES ('bob2', 'bob2', 'bubba2')
INSERT INTO dbo.SampleItems (name, firstname, lastname) VALUES ('bob3', 'bob3', 'bubba3')
INSERT INTO dbo.SampleItems (name, firstname, lastname) VALUES ('bob4', 'bob4', 'bubba4')
INSERT INTO dbo.SampleItems (name, firstname, lastname) VALUES ('bob5', 'bob5', 'bubba5')
4 changes: 4 additions & 0 deletions product/roundhouse.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ private static void parse_arguments_and_set_up_configuration(ConfigurationProper
string.Format("SprocsFolderName - The name of the folder where you keep your stored procedures. Will recurse through subfolders. Defaults to \"{0}\".",
ApplicationParameters.default_sprocs_folder_name),
option => configuration.SprocsFolderName = option)
.Add("ra=|runAfterOtherAnyTimeScripts=|runAfterOtherAnyTimeScriptsfolder=|runAfterOtherAnyTimeScriptsfoldername=",
string.Format("RunAfterOtherAnyTimeScriptsFolderName - The name of the folder where you keep scripts that will be run after all of the other any time scripts complete. Will recurse through subfolders. Defaults to \"{0}\".",
ApplicationParameters.default_runAfterOtherAnyTime_folder_name),
option => configuration.RunAfterOtherAnyTimeScriptsFolderName = option)
.Add("p=|permissions=|permissionsfolder=|permissionsfoldername=",
string.Format("PermissionsFolderName - The name of the folder where you keep your permissions scripts. Will recurse through subfolders. Defaults to \"{0}\".",
ApplicationParameters.default_permissions_folder_name),
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 @@ -67,6 +67,8 @@ bool ITask.Execute()

public string SprocsFolderName { get; set; }

public string RunAfterOtherAnyTimeScriptsFolderName { get; set; }

public string PermissionsFolderName { get; set; }

public string SchemaName { get; set; }
Expand Down
1 change: 1 addition & 0 deletions product/roundhouse/consoles/ConsoleConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public sealed class ConsoleConfiguration : ConfigurationPropertyHolder
public string FunctionsFolderName { get; set; }
public string ViewsFolderName { get; set; }
public string SprocsFolderName { get; set; }
public string RunAfterOtherAnyTimeScriptsFolderName { get; set; }
public string PermissionsFolderName { get; set; }
public string SchemaName { get; set; }
public string VersionTableName { get; set; }
Expand Down
67 changes: 35 additions & 32 deletions product/roundhouse/folders/DefaultKnownFolders.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
namespace roundhouse.folders
{
public sealed class DefaultKnownFolders : KnownFolders
{
public DefaultKnownFolders(MigrationsFolder up,
MigrationsFolder down,
MigrationsFolder run_first_after_up,
MigrationsFolder functions,
MigrationsFolder views,
MigrationsFolder sprocs,
MigrationsFolder permissions,
Folder change_drop
)
{
this.up = up;
this.down = down;
this.run_first_after_up = run_first_after_up;
this.functions = functions;
this.views = views;
namespace roundhouse.folders
{
public sealed class DefaultKnownFolders : KnownFolders
{
public DefaultKnownFolders(MigrationsFolder up,
MigrationsFolder down,
MigrationsFolder run_first_after_up,
MigrationsFolder functions,
MigrationsFolder views,
MigrationsFolder sprocs,
MigrationsFolder runAfterOtherAnyTimeScripts,
MigrationsFolder permissions,
Folder change_drop
)
{
this.up = up;
this.down = down;
this.run_first_after_up = run_first_after_up;
this.functions = functions;
this.views = views;
this.sprocs = sprocs;
this.permissions = permissions;
this.change_drop = change_drop;
}

public MigrationsFolder up { get; private set; }
public MigrationsFolder down { get; private set; }
public MigrationsFolder run_first_after_up { get; private set; }
public MigrationsFolder functions { get; private set; }
public MigrationsFolder views { get; private set; }
this.runAfterOtherAnyTimeScripts = runAfterOtherAnyTimeScripts;
this.permissions = permissions;
this.change_drop = change_drop;
}

public MigrationsFolder up { get; private set; }
public MigrationsFolder down { get; private set; }
public MigrationsFolder run_first_after_up { get; private set; }
public MigrationsFolder functions { get; private set; }
public MigrationsFolder views { get; private set; }
public MigrationsFolder sprocs { get; private set; }
public MigrationsFolder permissions { get; private set; }
public Folder change_drop{get; private set;}

}
public MigrationsFolder runAfterOtherAnyTimeScripts { get; private set; }
public MigrationsFolder permissions { get; private set; }
public Folder change_drop{get; private set;}

}
}
25 changes: 13 additions & 12 deletions product/roundhouse/folders/KnownFolders.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
namespace roundhouse.folders
{
public interface KnownFolders
{
MigrationsFolder up { get; }
MigrationsFolder down { get; }
MigrationsFolder run_first_after_up { get; }
MigrationsFolder functions { get; }
MigrationsFolder views { get; }
namespace roundhouse.folders
{
public interface KnownFolders
{
MigrationsFolder up { get; }
MigrationsFolder down { get; }
MigrationsFolder run_first_after_up { get; }
MigrationsFolder functions { get; }
MigrationsFolder views { get; }
MigrationsFolder sprocs { get; }
MigrationsFolder permissions { get; }
Folder change_drop { get; }
}
MigrationsFolder runAfterOtherAnyTimeScripts { get; }
MigrationsFolder permissions { get; }
Folder change_drop { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public static void set_defaults_if_properties_are_not_set(ConfigurationPropertyH
{
configuration_property_holder.SprocsFolderName = ApplicationParameters.default_sprocs_folder_name;
}
if (string.IsNullOrEmpty(configuration_property_holder.RunAfterOtherAnyTimeScriptsFolderName))
{
configuration_property_holder.RunAfterOtherAnyTimeScriptsFolderName = ApplicationParameters.default_runAfterOtherAnyTime_folder_name;
}
if (string.IsNullOrEmpty(configuration_property_holder.PermissionsFolderName))
{
configuration_property_holder.PermissionsFolderName = ApplicationParameters.default_permissions_folder_name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public interface ConfigurationPropertyHolder
string FunctionsFolderName { get; set; }
string ViewsFolderName { get; set; }
string SprocsFolderName { get; set; }
string RunAfterOtherAnyTimeScriptsFolderName { get; set; }
string PermissionsFolderName { get; set; }
string SchemaName { get; set; }
string VersionTableName { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public static KnownFolders build(FileSystemAccess file_system, ConfigurationProp
configuration_property_holder.ViewsFolderName, false, false);
MigrationsFolder sprocs_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory,
configuration_property_holder.SprocsFolderName, false, false);

MigrationsFolder runAfterOtherAnyTimeScripts_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory,
configuration_property_holder.RunAfterOtherAnyTimeScriptsFolderName, false, false);

MigrationsFolder permissions_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory,
configuration_property_holder.PermissionsFolderName, false, true);
Folder change_drop_folder = new DefaultFolder(file_system, combine_items_into_one_path(file_system,
Expand All @@ -28,8 +32,8 @@ public static KnownFolders build(FileSystemAccess file_system, ConfigurationProp
configuration_property_holder.ServerName),
get_run_date_time_string());

return new DefaultKnownFolders(up_folder, down_folder, run_first_folder, functions_folder, views_folder, sprocs_folder,
permissions_folder, change_drop_folder);
return new DefaultKnownFolders(up_folder, down_folder, run_first_folder, functions_folder, views_folder, sprocs_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 @@ -13,6 +13,7 @@ public static class ApplicationParameters
public readonly static string default_functions_folder_name = "functions";
public readonly static string default_views_folder_name = "views";
public readonly static string default_sprocs_folder_name = "sprocs";
public readonly static string default_runAfterOtherAnyTime_folder_name = "runAfterOtherAnyTimeScripts";
public readonly static string default_permissions_folder_name = "permissions";
public readonly static string default_environment_name = "LOCAL";
public readonly static string default_roundhouse_schema_name = "RoundhousE";
Expand Down
6 changes: 6 additions & 0 deletions product/roundhouse/runners/RoundhouseMigrationRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ public void run()
Log.bound_to(this).log_an_info_event_containing("Looking for {0} scripts in \"{1}\".", "Stored Procedure", known_folders.sprocs.folder_full_path);
Log.bound_to(this).log_an_info_event_containing("{0}", "-".PadRight(50, '-'));
traverse_files_and_run_sql(known_folders.sprocs.folder_full_path, version_id, known_folders.sprocs, environment, new_version);

Log.bound_to(this).log_an_info_event_containing("{0}", "-".PadRight(50, '-'));
Log.bound_to(this).log_an_info_event_containing("Looking for {0} scripts in \"{1}\".", "Run after Other Anytime Scripts", known_folders.runAfterOtherAnyTimeScripts.folder_full_path);
Log.bound_to(this).log_an_info_event_containing("{0}", "-".PadRight(50, '-'));
traverse_files_and_run_sql(known_folders.runAfterOtherAnyTimeScripts.folder_full_path, version_id, known_folders.runAfterOtherAnyTimeScripts, environment, new_version);

Log.bound_to(this).log_an_info_event_containing("{0}", "-".PadRight(50, '-'));
Log.bound_to(this).log_an_info_event_containing("Looking for {0} scripts in \"{1}\". These scripts will run every time.", "Permission", known_folders.permissions.folder_full_path);
Log.bound_to(this).log_an_info_event_containing("{0}", "-".PadRight(50, '-'));
Expand Down

0 comments on commit 59b4732

Please sign in to comment.