diff --git a/product/roundhouse.console/Program.cs b/product/roundhouse.console/Program.cs index 2c947eb..1961732 100644 --- a/product/roundhouse.console/Program.cs +++ b/product/roundhouse.console/Program.cs @@ -3,6 +3,7 @@ using System; using System.Reflection; using consoles; + using databases; using folders; using infrastructure; using infrastructure.app; @@ -14,6 +15,7 @@ using log4net; using log4net.Core; using log4net.Repository; + using log4net.Repository.Hierarchy; using migrators; using resolvers; using runners; @@ -61,14 +63,15 @@ public static ConfigurationPropertyHolder set_up_configuration_and_build_the_con { ConfigurationPropertyHolder configuration = new DefaultConfiguration(); parse_arguments_and_set_up_configuration(configuration, args); + + ApplicationConfiguraton.set_defaults_if_properties_are_not_set(configuration); + ApplicationConfiguraton.build_the_container(configuration); + if (configuration.Debug) { change_log_to_debug_level(); } - - ApplicationConfiguraton.set_defaults_if_properties_are_not_set(configuration); - ApplicationConfiguraton.build_the_container(configuration); - + return configuration; } @@ -254,10 +257,13 @@ private static void parse_arguments_and_set_up_configuration(ConfigurationProper .Add("t|trx|transaction|wt|withtransaction", "WithTransaction - This instructs RH to run inside of a transaction. Defaults to false.", option => configuration.WithTransaction = option != null) - //simple + //recovery mode .Add("simple", "RecoveryModeSimple - This instructs RH to set the database recovery mode to simple recovery. Defaults to false.", option => configuration.RecoveryModeSimple = option != null) + .Add("rcm=|recoverymode=", + "RecoveryMode - This instructs RH to set the database recovery mode to Simple|Full|NoChange. Defaults to NoChange.", + option => configuration.RecoveryMode = (RecoveryMode)Enum.Parse(typeof(RecoveryMode),option,true)) //debug .Add("debug", "Debug - This instructs RH to write out all messages. Defaults to false.", @@ -319,7 +325,7 @@ private static void parse_arguments_and_set_up_configuration(ConfigurationProper "/drop " + "/d[onot]c[reatedatabase] " + "/t[ransaction] " + - "/simple " + + "/r[e]c[overy]m[ode] NoChange|Simple|Full" + "/debug " + "/runallanytimescripts " + "/disabletokenreplacement " + @@ -355,6 +361,14 @@ public static void change_log_to_debug_level() { ILoggerRepository log_repository = LogManager.GetRepository(Assembly.GetCallingAssembly()); log_repository.Threshold = Level.Debug; + foreach (ILogger log in log_repository.GetCurrentLoggers()) + { + var logger = log as log4net.Repository.Hierarchy.Logger; + if (logger != null) + { + logger.Level = log4net.Core.Level.Debug; + } + } } public static void run_migrator(ConfigurationPropertyHolder configuration) diff --git a/product/roundhouse.tasks/DBDeploy_MSBuild.proj b/product/roundhouse.tasks/DBDeploy_MSBuild.proj index 9b9e9d8..77a3be1 100644 --- a/product/roundhouse.tasks/DBDeploy_MSBuild.proj +++ b/product/roundhouse.tasks/DBDeploy_MSBuild.proj @@ -60,7 +60,7 @@ Silent="false" DatabaseType="roundhouse.databases.sqlserver.SqlServerDatabase, roundhouse" WithTransaction="false" - RecoveryModeSimple="false" + RecoveryMode="Full" RunAllAnyTimeScripts="false" DisableTokenReplacement="false" /> diff --git a/product/roundhouse.tasks/Roundhouse.cs b/product/roundhouse.tasks/Roundhouse.cs index 1bff054..ec0dddc 100644 --- a/product/roundhouse.tasks/Roundhouse.cs +++ b/product/roundhouse.tasks/Roundhouse.cs @@ -1,6 +1,7 @@ namespace roundhouse.tasks { using System; + using databases; using folders; using infrastructure.app; using infrastructure.app.logging; @@ -112,6 +113,9 @@ bool ITask.Execute() public bool WithTransaction { get; set; } + public RecoveryMode RecoveryMode { get; set; } + + [Obsolete("Use RecoverMode=Simple now")] public bool RecoveryModeSimple { get; set; } public bool Debug { get; set; } diff --git a/product/roundhouse.tasks/samples.xml b/product/roundhouse.tasks/samples.xml index aad22ae..b4a3f29 100644 --- a/product/roundhouse.tasks/samples.xml +++ b/product/roundhouse.tasks/samples.xml @@ -77,7 +77,7 @@ Silent="false" DatabaseType="roundhouse.databases.sqlserver.SqlServerDatabase, roundhouse" WithTransaction="false" - RecoveryModeSimple="false" + RecoveryMode="Simple" RunAllAnyTimeScripts="false" DisableTokenReplacement="false" /> diff --git a/product/roundhouse/RoundhousEFluentNHibernateDiffingType.cs b/product/roundhouse/RoundhousEFluentNHibernateDiffingType.cs index a8e3cc9..00e720b 100644 --- a/product/roundhouse/RoundhousEFluentNHibernateDiffingType.cs +++ b/product/roundhouse/RoundhousEFluentNHibernateDiffingType.cs @@ -1,5 +1,8 @@ namespace roundhouse { + using System; + + [Obsolete("Use RoundhouseMode",true)] public enum RoundhousEFluentNHDiffingType { InitialDevelopment, diff --git a/product/roundhouse/RoundhouseMode.cs b/product/roundhouse/RoundhouseMode.cs new file mode 100644 index 0000000..5903d36 --- /dev/null +++ b/product/roundhouse/RoundhouseMode.cs @@ -0,0 +1,9 @@ +namespace roundhouse +{ + public enum RoundhouseMode + { + InitialDevelopment, + Maintenance, + MaintenanceWithRestore + } +} \ No newline at end of file diff --git a/product/roundhouse/consoles/DefaultConfiguration.cs b/product/roundhouse/consoles/DefaultConfiguration.cs index 8c5b979..c6e9d80 100644 --- a/product/roundhouse/consoles/DefaultConfiguration.cs +++ b/product/roundhouse/consoles/DefaultConfiguration.cs @@ -1,5 +1,7 @@ namespace roundhouse.consoles { + using System; + using databases; using infrastructure.app; using infrastructure.logging; @@ -33,7 +35,7 @@ public sealed class DefaultConfiguration : ConfigurationPropertyHolder public string ScriptsRunErrorsTableName { get; set; } public string EnvironmentName { get; set; } public bool Restore { get; set; } - public string RestoreFromPath { get; set; } + public string RestoreFromPath { get; set; } public string RestoreCustomOptions { get; set; } public int RestoreTimeout { get; set; } public string CreateDatabaseCustomScript { get; set; } @@ -44,6 +46,8 @@ public sealed class DefaultConfiguration : ConfigurationPropertyHolder public bool Drop { get; set; } public bool DoNotCreateDatabase { get; set; } public bool WithTransaction { get; set; } + public RecoveryMode RecoveryMode { get; set; } + [Obsolete("Use RecoveryMode = Simple")] public bool RecoveryModeSimple { get; set; } public bool Debug { get; set; } public bool DryRun { get; set; } diff --git a/product/roundhouse/databases/RecoveryMode.cs b/product/roundhouse/databases/RecoveryMode.cs new file mode 100644 index 0000000..f76743f --- /dev/null +++ b/product/roundhouse/databases/RecoveryMode.cs @@ -0,0 +1,9 @@ +namespace roundhouse.databases +{ + public enum RecoveryMode + { + NoChange, + Simple, + Full + } +} \ No newline at end of file diff --git a/product/roundhouse/infrastructure.app/ApplicationConfiguraton.cs b/product/roundhouse/infrastructure.app/ApplicationConfiguraton.cs index feeb591..73d7acd 100644 --- a/product/roundhouse/infrastructure.app/ApplicationConfiguraton.cs +++ b/product/roundhouse/infrastructure.app/ApplicationConfiguraton.cs @@ -128,11 +128,14 @@ public static void set_defaults_if_properties_are_not_set(ConfigurationPropertyH { configuration_property_holder.RestoreTimeout = ApplicationParameters.default_restore_timeout; } - if (!string.IsNullOrEmpty(configuration_property_holder.RestoreFromPath)) { configuration_property_holder.RestoreFromPath = Path.GetFullPath(configuration_property_holder.RestoreFromPath); } + if (configuration_property_holder.RecoveryModeSimple) + { + configuration_property_holder.RecoveryMode = RecoveryMode.Simple; + } } private static void set_up_current_mappings(ConfigurationPropertyHolder configuration_property_holder) diff --git a/product/roundhouse/infrastructure.app/ConfigurationPropertyHolder.cs b/product/roundhouse/infrastructure.app/ConfigurationPropertyHolder.cs index 359e5b3..bc4bb1f 100644 --- a/product/roundhouse/infrastructure.app/ConfigurationPropertyHolder.cs +++ b/product/roundhouse/infrastructure.app/ConfigurationPropertyHolder.cs @@ -2,6 +2,9 @@ namespace roundhouse.infrastructure.app { + using System; + using databases; + public interface ConfigurationPropertyHolder { Logger Logger { get; set; } @@ -43,6 +46,8 @@ public interface ConfigurationPropertyHolder bool Drop { get; set; } bool DoNotCreateDatabase { get; set; } bool WithTransaction { get; set; } + RecoveryMode RecoveryMode { get; set; } + [Obsolete("Use RecoveryMode = Simple")] bool RecoveryModeSimple { get; set; } bool Debug { get; set; } bool DryRun { get; set; } diff --git a/product/roundhouse/roundhouse.csproj b/product/roundhouse/roundhouse.csproj index b666f07..4374487 100644 --- a/product/roundhouse/roundhouse.csproj +++ b/product/roundhouse/roundhouse.csproj @@ -110,6 +110,7 @@ + @@ -134,6 +135,7 @@ + diff --git a/product/roundhouse/runners/RoundhouseMigrationRunner.cs b/product/roundhouse/runners/RoundhouseMigrationRunner.cs index f35d97f..be3dfa8 100644 --- a/product/roundhouse/runners/RoundhouseMigrationRunner.cs +++ b/product/roundhouse/runners/RoundhouseMigrationRunner.cs @@ -1,6 +1,7 @@ namespace roundhouse.runners { using System; + using databases; using folders; using infrastructure; using infrastructure.app; @@ -105,7 +106,11 @@ public void run() { database_migrator.open_admin_connection(); database_was_created = database_migrator.create_or_restore_database(get_custom_create_database_script()); - database_migrator.set_recovery_mode(use_simple_recovery); + if (configuration.RecoveryMode != RecoveryMode.NoChange) + { + database_migrator.set_recovery_mode(configuration.RecoveryMode == RecoveryMode.Simple); + } + database_migrator.close_admin_connection(); } database_migrator.open_connection(run_in_a_transaction); @@ -119,8 +124,7 @@ public void run() Log.bound_to(this).log_an_info_event_containing("{0}", "=".PadRight(50, '=')); string current_version = database_migrator.get_current_version(repository_path); string new_version = version_resolver.resolve_version(); - Log.bound_to(this).log_an_info_event_containing(" Migrating {0} from version {1} to {2}.", database_migrator.database.database_name, - current_version, new_version); + Log.bound_to(this).log_an_info_event_containing(" Migrating {0} from version {1} to {2}.", database_migrator.database.database_name,current_version, new_version); long version_id = database_migrator.version_the_database(repository_path, new_version); Log.bound_to(this).log_an_info_event_containing("{0}", "=".PadRight(50, '='));