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

Topic/run after other any time scripts initial work #1

Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Simple script. Can actually call sprocs defined elsewhere because this is run after all of the other anytime scripts

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 @@ -144,6 +144,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 @@ -75,6 +75,8 @@ public ITask MSBuildTask

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 @@ -31,6 +31,7 @@ public ITask MSBuildTask
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
7 changes: 5 additions & 2 deletions product/roundhouse/folders/DefaultKnownFolders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public DefaultKnownFolders(MigrationsFolder up,
MigrationsFolder functions,
MigrationsFolder views,
MigrationsFolder sprocs,
MigrationsFolder runAfterOtherAnyTimeScripts,
MigrationsFolder permissions,
Folder change_drop
)
Expand All @@ -17,7 +18,8 @@ Folder change_drop
this.run_first_after_up = run_first_after_up;
this.functions = functions;
this.views = views;
this.sprocs = sprocs;
this.sprocs = sprocs;
this.runAfterOtherAnyTimeScripts = runAfterOtherAnyTimeScripts;
this.permissions = permissions;
this.change_drop = change_drop;
}
Expand All @@ -27,7 +29,8 @@ Folder change_drop
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 sprocs { get; private set; }
public MigrationsFolder runAfterOtherAnyTimeScripts { get; private set; }
public MigrationsFolder permissions { get; private set; }
public Folder change_drop{get; private set;}

Expand Down
3 changes: 2 additions & 1 deletion product/roundhouse/folders/KnownFolders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ public interface KnownFolders
MigrationsFolder run_first_after_up { get; }
MigrationsFolder functions { get; }
MigrationsFolder views { get; }
MigrationsFolder sprocs { get; }
MigrationsFolder sprocs { get; }
MigrationsFolder runAfterOtherAnyTimeScripts { get; }
MigrationsFolder permissions { get; }
Folder change_drop { get; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,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 @@ -22,6 +22,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