diff --git a/product/roundhouse.console/Program.cs b/product/roundhouse.console/Program.cs index 307bc36e..5d160822 100644 --- a/product/roundhouse.console/Program.cs +++ b/product/roundhouse.console/Program.cs @@ -359,6 +359,10 @@ private static void parse_arguments_and_set_up_configuration(ConfigurationProper .Add("isuptodate", "This option prints whether there are any database updates or not, without actually running them. Other output except errors is disabled, to make it easy to use in scripts.", option => { }) + //do not store full text of run scripts + .Add("donotstorescriptsruntext", + "DoNotStoreScriptsRunText - This instructs RH to not store the full script text in the database. Defaults to false.", + option => configuration.DoNotStoreScriptsRunText = option != null) // default encoding .Add("defaultencoding=", "Default encoding to use for loading script file from disk if file doesn't contain BOM. For the list of possible values see the column Name in table listed in .NET Encoding class documentation. Defaults to UTF-8", diff --git a/product/roundhouse.core/consoles/DefaultConfiguration.cs b/product/roundhouse.core/consoles/DefaultConfiguration.cs index cc19ac4a..2aa4dbd9 100644 --- a/product/roundhouse.core/consoles/DefaultConfiguration.cs +++ b/product/roundhouse.core/consoles/DefaultConfiguration.cs @@ -46,6 +46,7 @@ public DefaultConfiguration() public string VersionTableName { get; set; } public string ScriptsRunTableName { get; set; } public string ScriptsRunErrorsTableName { get; set; } + public bool DoNotStoreScriptsRunText { get; set; } [Obsolete("Use EnvironmentNames")] public string EnvironmentName { get { return EnvironmentNames.SingleOrDefault(); } @@ -105,6 +106,7 @@ public IDictionary to_token_dictionary() tokens["DisableTokenReplacement"] = DisableTokenReplacement.to_string(); tokens["DoNotAlterDatabase"] = DoNotAlterDatabase.to_string(); tokens["DoNotCreateDatabase"] = DoNotCreateDatabase.to_string(); + tokens["DoNotStoreScriptsRunText"] = DoNotStoreScriptsRunText.to_string(); tokens["DownFolderName"] = DownFolderName.to_string(); tokens["Drop"] = Drop.to_string(); tokens["DryRun"] = DryRun.to_string(); diff --git a/product/roundhouse.core/infrastructure.app/ConfigurationPropertyHolder.cs b/product/roundhouse.core/infrastructure.app/ConfigurationPropertyHolder.cs index 00263e29..f343583c 100644 --- a/product/roundhouse.core/infrastructure.app/ConfigurationPropertyHolder.cs +++ b/product/roundhouse.core/infrastructure.app/ConfigurationPropertyHolder.cs @@ -40,6 +40,7 @@ public interface ConfigurationPropertyHolder string VersionTableName { get; set; } string ScriptsRunTableName { get; set; } string ScriptsRunErrorsTableName { get; set; } + bool DoNotStoreScriptsRunText { get; set; } [Obsolete("Use EnvironmentNames")] string EnvironmentName { get; set; } IList EnvironmentNames { get; } diff --git a/product/roundhouse.core/migrators/DefaultDatabaseMigrator.cs b/product/roundhouse.core/migrators/DefaultDatabaseMigrator.cs index 7e98d199..2963b4be 100644 --- a/product/roundhouse.core/migrators/DefaultDatabaseMigrator.cs +++ b/product/roundhouse.core/migrators/DefaultDatabaseMigrator.cs @@ -255,12 +255,23 @@ public IEnumerable get_statements_to_run(string sql_to_run) public void record_script_in_scripts_run_table(string script_name, string sql_to_run, bool run_this_script_once, long version_id) { + var hash = hash_generator.create_hash(sql_to_run, true); + if (configuration.DoNotStoreScriptsRunText) + { + sql_to_run = null; + } + Log.bound_to(this).log_a_debug_event_containing("Recording {0} script ran on {1} - {2}.", script_name, database.server_name, database.database_name); - database.insert_script_run(script_name, sql_to_run, hash_generator.create_hash(sql_to_run, true), run_this_script_once, version_id); + database.insert_script_run(script_name, sql_to_run, hash, run_this_script_once, version_id); } public void record_script_in_scripts_run_errors_table(string script_name, string sql_to_run, string sql_erroneous_part, string error_message, string repository_version, string repository_path) { + if (configuration.DoNotStoreScriptsRunText) + { + sql_to_run = null; + } + Log.bound_to(this).log_a_debug_event_containing("Recording {0} script ran with error on {1} - {2}.", script_name, database.server_name, database.database_name); database.insert_script_run_error(script_name, sql_to_run, sql_erroneous_part, error_message, repository_version, repository_path); } @@ -367,4 +378,4 @@ public bool this_is_an_environment_file_and_its_in_the_right_environment(string return environment_file_is_in_the_right_environment; } } -} \ No newline at end of file +} diff --git a/product/roundhouse.tasks/Roundhouse.cs b/product/roundhouse.tasks/Roundhouse.cs index 08925991..9732cb90 100644 --- a/product/roundhouse.tasks/Roundhouse.cs +++ b/product/roundhouse.tasks/Roundhouse.cs @@ -112,6 +112,8 @@ bool ITask.Execute() public string ScriptsRunErrorsTableName { get; set; } + public bool DoNotStoreScriptsRunText { get; set; } + [Obsolete("Use EnvironmentNames")] public string EnvironmentName { get { return EnvironmentNames.SingleOrDefault(); } @@ -229,6 +231,7 @@ public IDictionary to_token_dictionary() { nameof(DisableTokenReplacement), DisableTokenReplacement.to_string() }, { nameof(DoNotAlterDatabase), DoNotAlterDatabase.to_string() }, { nameof(DoNotCreateDatabase), DoNotCreateDatabase.to_string() }, + { nameof(DoNotStoreScriptsRunText), DoNotStoreScriptsRunText.to_string() }, { nameof(DownFolderName), DownFolderName.to_string() }, { nameof(Drop), Drop.to_string() }, { nameof(DryRun), DryRun.to_string() },