public static void build_the_container(ConfigurationPropertyHolder configuration_property_holder) { Container.initialize_with(null); Container.initialize_with(build_items_for_container(configuration_property_holder)); initialize_file_log_appender(); set_logging_level_debug_when_debug(configuration_property_holder); }
private static Logger GetMultiLogger(ConfigurationPropertyHolder configuration_property_holder) { IList <Logger> loggers = new List <Logger>(); // This doesn't work on macOS, at least. Try, and fail silently. try { var task = configuration_property_holder as ITask; if (task != null) { Logger msbuild_logger = new MSBuildLogger(configuration_property_holder); loggers.Add(msbuild_logger); } } catch (FileNotFoundException) {} Logger log4net_logger = new Log4NetLogger(LogManager.GetLogger(typeof(ApplicationConfiguraton))); loggers.Add(log4net_logger); if (configuration_property_holder.Logger != null && !loggers.Contains(configuration_property_holder.Logger)) { loggers.Add(configuration_property_holder.Logger); } return(new MultipleLogger(loggers)); }
public override void initialize_connections(ConfigurationPropertyHolder configuration_property_holder) { if (!string.IsNullOrEmpty(connection_string)) { string[] parts = connection_string.Split(';'); foreach (string part in parts) { if (string.IsNullOrEmpty(server_name) && (part.to_lower().Contains("server") || part.to_lower().Contains("data source"))) { server_name = part.Substring(part.IndexOf("=") + 1); } if (string.IsNullOrEmpty(database_name) && (part.to_lower().Contains("database") || part.to_lower().Contains("database"))) { database_name = part.Substring(part.IndexOf("=") + 1); } } } configuration_property_holder.ConnectionString = connection_string; set_provider(); if (string.IsNullOrEmpty(admin_connection_string)) { var builder = new MySqlConnectionStringBuilder(connection_string); builder.Database = "information_schema"; admin_connection_string = builder.ConnectionString; } }
public RoundhouseRedGateCompareRunner(KnownFolders known_folders, FileSystemAccess file_system, ConfigurationPropertyHolder configuration, RoundhouseMigrationRunner migration_runner) { this.known_folders = known_folders; this.file_system = file_system; this.configuration = configuration; this.migration_runner = migration_runner; }
private static RoundhouseRedGateCompareRunner get_diff_runner(ConfigurationPropertyHolder configuration, RoundhouseMigrationRunner migration_runner) { return(new RoundhouseRedGateCompareRunner( Container.get_an_instance_of <KnownFolders>(), Container.get_an_instance_of <FileSystemAccess>(), configuration, migration_runner)); }
//private const string proxy_factory = Environment.ProxyFactoryFactoryClass; public NHibernateSessionFactoryBuilder(ConfigurationPropertyHolder config) { configuration_holder = config; func_dictionary = new Dictionary<string, Func<IPersistenceConfigurer>>(); func_dictionary.Add("roundhouse.databases.sqlserver.SqlServerDatabase, roundhouse.databases.sqlserver", () => MsSqlConfiguration.MsSql2005.ConnectionString(configuration_holder.ConnectionString)); func_dictionary.Add("roundhouse.databases.sqlserver2000.SqlServerDatabase, roundhouse.databases.sqlserver2000", () => MsSqlConfiguration.MsSql2000.ConnectionString(configuration_holder.ConnectionString)); func_dictionary.Add("roundhouse.databases.mysql.MySqlDatabase, roundhouse.databases.mysql", () => MySQLConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString)); func_dictionary.Add("roundhouse.databases.oracle.OracleDatabase, roundhouse.databases.oracle", () => OracleClientConfiguration.Oracle9.ConnectionString(configuration_holder.ConnectionString)); func_dictionary.Add("roundhouse.databases.access.AccessDatabase, roundhouse.databases.access", () => JetDriverConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString)); func_dictionary.Add("roundhouse.databases.sqlite.SqliteDatabase, roundhouse.databases.sqlite", () => SQLiteConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString)); func_dictionary.Add("roundhouse.databases.postgresql.PostgreSQLDatabase, roundhouse.databases.postgresql", () => PostgreSQLConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString)); // merged string merged_assembly_name = ApplicationParameters.get_merged_assembly_name(); func_dictionary.Add("roundhouse.databases.sqlserver.SqlServerDatabase, " + merged_assembly_name, () => MsSqlConfiguration.MsSql2005.ConnectionString(configuration_holder.ConnectionString)); func_dictionary.Add("roundhouse.databases.sqlserver2000.SqlServerDatabase, " + merged_assembly_name, () => MsSqlConfiguration.MsSql2000.ConnectionString(configuration_holder.ConnectionString)); func_dictionary.Add("roundhouse.databases.mysql.MySqlDatabase, " + merged_assembly_name, () => MySQLConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString)); func_dictionary.Add("roundhouse.databases.oracle.OracleDatabase, " + merged_assembly_name, () => OracleClientConfiguration.Oracle9.ConnectionString(configuration_holder.ConnectionString)); func_dictionary.Add("roundhouse.databases.access.AccessDatabase, " + merged_assembly_name, () => JetDriverConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString)); func_dictionary.Add("roundhouse.databases.sqlite.SqliteDatabase, " + merged_assembly_name, () => SQLiteConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString)); func_dictionary.Add("roundhouse.databases.postgresql.PostgreSQLDatabase, " + merged_assembly_name, () => PostgreSQLConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString)); }
public static string replace_tokens(ConfigurationPropertyHolder configuration, string text_to_replace) { if (string.IsNullOrEmpty(text_to_replace)) { return(string.Empty); } IDictionary <string, string> dictionary = create_dictionary_from_configuration(configuration); Regex regex = new Regex("{{(?<key>\\w+)}}"); string output = regex.Replace(text_to_replace, m => { string key = ""; key = m.Groups["key"].Value.to_lower(); if (!dictionary.ContainsKey(key)) { return("{{" + key + "}}"); } var value = dictionary[key]; return(value); }); return(output); }
public static KnownFolders build(FileSystemAccess file_system, ConfigurationPropertyHolder configuration_property_holder) { MigrationsFolder alter_database_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.AlterDatabaseFolderName,false,false); MigrationsFolder run_after_create_database_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.RunAfterCreateDatabaseFolderName,true,false); MigrationsFolder up_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.UpFolderName, true, false); MigrationsFolder down_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.DownFolderName, true, false); MigrationsFolder run_first_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.RunFirstAfterUpFolderName, false, false); MigrationsFolder functions_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.FunctionsFolderName, false, false); MigrationsFolder views_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.ViewsFolderName, false, false); MigrationsFolder sprocs_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.SprocsFolderName, false, false); MigrationsFolder indexes_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.IndexesFolderName, 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, configuration_property_holder.OutputPath, configuration_property_holder.DatabaseName, configuration_property_holder.ServerName), 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); }
public RoundhouseRedGateCompareRunner(KnownFolders known_folders, FileSystemAccess file_system, ConfigurationPropertyHolder configuration, RoundhouseMigrationRunner migration_runner) { this.known_folders = known_folders; this.file_system = file_system; this.configuration = configuration; this.migration_runner = migration_runner; }
private void run_changes(Migrate migrator, ConfigurationPropertyHolder configuration, Assembly migrations_assembly) { var files_directory = configuration.SqlFilesDirectory; configuration.SqlFilesDirectory = "."; bool restoring_the_database = RefreshDatabaseParameters.RestoreDatabase; var initial_development = RefreshDatabaseParameters.DropDatabaseFirst; if (initial_development) { migrator.RunDropCreate(); } else if (restoring_the_database) { configuration.Restore = true; migrator.RunRestore(); } else { migrator.Run(); } generate_database_changes(migrations_assembly); Console.WriteLine("NOTE: To regenerate files you need to first delete them from the file system."); configuration.SqlFilesDirectory = files_directory; configuration.Restore = false; migrator.Run(); }
public RoundhouseMigrationRunner( string repository_path, Environment environment, KnownFolders known_folders, FileSystemAccess file_system, DatabaseMigrator database_migrator, VersionResolver version_resolver, bool silent, bool dropping_the_database, bool dont_create_the_database, bool run_in_a_transaction, bool use_simple_recovery, ConfigurationPropertyHolder configuration) { this.known_folders = known_folders; this.repository_path = repository_path; this.environment = environment; this.file_system = file_system; this.database_migrator = database_migrator; this.version_resolver = version_resolver; this.silent = silent; this.dropping_the_database = dropping_the_database; this.dont_create_the_database = dont_create_the_database; this.run_in_a_transaction = run_in_a_transaction; this.use_simple_recovery = use_simple_recovery; this.configuration = configuration; }
private void LoadCommonRoundHouseSettings(string workingDirectory, ConfigurationPropertyHolder c) { c.RecoveryMode = RecoveryMode.NoChange; c.RepositoryPath = StaticRoundHouseSettings.RepositoryPath; c.SchemaName = StaticRoundHouseSettings.SchemaName; c.ScriptsRunErrorsTableName = StaticRoundHouseSettings.ScriptsRunErrorsTableName; c.ScriptsRunTableName = StaticRoundHouseSettings.ScriptsRunTableName; c.SearchAllSubdirectoriesInsteadOfTraverse = StaticRoundHouseSettings.SearchAllSubdirectoriesInsteadOfTraverse; c.Silent = StaticRoundHouseSettings.Silent; c.RunAllAnyTimeScripts = StaticRoundHouseSettings.RunAllAnyTimeScripts; c.VersionTableName = StaticRoundHouseSettings.VersionTableName; c.WarnOnOneTimeScriptChanges = StaticRoundHouseSettings.WarnOnOneTimeScriptChanges; c.WithTransaction = StaticRoundHouseSettings.WithTransaction; c.OutputPath = DeploymentDirectoryStructureConstants.OutputPath; c.VersionFile = Path.Combine(workingDirectory, DeploymentDirectoryStructureConstants.VersionFile); c.VersionXPath = DeploymentDirectoryStructureConstants.VersionXPath; c.DryRun = DeploymentDirectoryStructureConstants.DryRun; c.Restore = this.Restore; c.RestoreCustomOptions = this.RestoreCustomOptions; c.RestoreFromPath = this.RestoreFromPath; c.RestoreTimeout = this.RestoreTimeout; c.DatabaseName = StaticRoundHouseSettings.DatabaseName; c.DatabaseType = StaticRoundHouseSettings.DatabaseType; c.Debug = StaticRoundHouseSettings.Debug; c.DisableOutput = StaticRoundHouseSettings.DisableOutput; c.DisableTokenReplacement = StaticRoundHouseSettings.DisableTokenReplacement; c.DoNotCreateDatabase = StaticRoundHouseSettings.DoNotCreateDatabase; c.Drop = StaticRoundHouseSettings.Drop; c.EnvironmentName = StaticRoundHouseSettings.EnvironmentName; c.CommandTimeout = StaticRoundHouseSettings.CommandTimeout; c.CommandTimeoutAdmin = StaticRoundHouseSettings.CommandTimeoutAdmin; }
public override void Context() { migrator = new Migrate().Set(p => { p.Logger = new ConsoleLogger(); p.DatabaseName = database_name; p.SqlFilesDirectory = sql_files_folder; p.Silent = true; }); migrator.Run(); ConfigurationPropertyHolder configuration_property_holder = migrator.GetConfiguration(); ApplicationConfiguraton.set_defaults_if_properties_are_not_set(configuration_property_holder); db.configuration = configuration_property_holder; db.server_name = configuration_property_holder.ServerName ?? string.Empty; db.database_name = configuration_property_holder.DatabaseName ?? string.Empty; db.connection_string = configuration_property_holder.ConnectionString; db.admin_connection_string = configuration_property_holder.ConnectionStringAdmin; db.roundhouse_schema_name = configuration_property_holder.SchemaName; db.version_table_name = configuration_property_holder.VersionTableName; db.scripts_run_table_name = configuration_property_holder.ScriptsRunTableName; db.scripts_run_errors_table_name = configuration_property_holder.ScriptsRunErrorsTableName; db.command_timeout = configuration_property_holder.CommandTimeout; db.admin_command_timeout = configuration_property_holder.CommandTimeoutAdmin; db.restore_timeout = configuration_property_holder.RestoreTimeout; db.initialize_connections(configuration_property_holder); }
private static RoundhouseRedGateCompareRunner get_diff_runner(ConfigurationPropertyHolder configuration, RoundhouseMigrationRunner migration_runner) { return new RoundhouseRedGateCompareRunner( Container.get_an_instance_of<KnownFolders>(), Container.get_an_instance_of<FileSystemAccess>(), configuration, migration_runner); }
public static KnownFolders build(FileSystemAccess file_system, ConfigurationPropertyHolder configuration_property_holder) { MigrationsFolder up_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.UpFolderName, true, false); MigrationsFolder down_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.DownFolderName, true, false); MigrationsFolder run_first_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.RunFirstAfterUpFolderName, false, false); MigrationsFolder functions_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.FunctionsFolderName, false, false); MigrationsFolder views_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.ViewsFolderName, false, false); MigrationsFolder sprocs_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.SprocsFolderName, 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, configuration_property_holder.OutputPath, configuration_property_holder.DatabaseName, 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)); }
public override void Context() { configuration_property_holder = new DefaultConfiguration { Logger = new Log4NetLogFactory().create_logger_bound_to(typeof(DbProviderFactories)) }; }
public override void Context() { configuration_property_holder = new DefaultConfiguration { Logger = new Log4NetLogFactory().create_logger_bound_to(typeof(SqlServerDatabaseSpecs)) }; }
public RoundhouseMigrationRunner( string repository_path, EnvironmentSet environment_set, KnownFolders known_folders, FileSystemAccess file_system, DatabaseMigrator database_migrator, VersionResolver version_resolver, bool silent, bool dropping_the_database, bool dont_create_the_database, bool run_in_a_transaction, ConfigurationPropertyHolder configuration) { this.known_folders = known_folders; this.repository_path = repository_path; this.environment_set = environment_set; this.file_system = file_system; this.database_migrator = database_migrator; this.version_resolver = version_resolver; this.silent = silent; this.dropping_the_database = dropping_the_database; this.dont_create_the_database = dont_create_the_database; this.run_in_a_transaction = run_in_a_transaction; this.configuration = configuration; }
public static string replace_tokens(ConfigurationPropertyHolder configuration, string text_to_replace) { if (string.IsNullOrEmpty(text_to_replace)) return string.Empty; IDictionary<string, string> dictionary = create_dictionary_from_configuration(configuration); Regex regex = new Regex("{{(?<key>\\w+)}}"); string output = regex.Replace(text_to_replace, m => { string key = ""; try { key = m.Groups["key"].Value.to_lower(); var value = dictionary[key]; return value; } catch (Exception) { throw; } }); return output; }
public static KnownFolders build(FileSystemAccess file_system, ConfigurationPropertyHolder configuration_property_holder) { 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 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"); MigrationsFolder views_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.ViewsFolderName, false, false, "View"); MigrationsFolder sprocs_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.SprocsFolderName, false, false, "Stored Procedure"); MigrationsFolder indexes_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.IndexesFolderName, false, false, "Index"); MigrationsFolder runAfterOtherAnyTimeScripts_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.RunAfterOtherAnyTimeScriptsFolderName, false, false, "Run after Other Anytime Scripts"); MigrationsFolder permissions_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.PermissionsFolderName, false, true, "Permission"); MigrationsFolder before_migration_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.BeforeMigrationFolderName, false, true, "BeforeMigration"); MigrationsFolder after_migration_folder = new DefaultMigrationsFolder(file_system, configuration_property_holder.SqlFilesDirectory, configuration_property_holder.AfterMigrationFolderName, false, true, "AfterMigration"); Folder change_drop_folder = new DefaultFolder(file_system, combine_items_into_one_path(file_system, configuration_property_holder.OutputPath, "migrations", remove_paths_from(configuration_property_holder.DatabaseName,file_system), 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, run_before_up_folder, up_folder, down_folder, run_first_folder, functions_folder, views_folder, sprocs_folder, indexes_folder, runAfterOtherAnyTimeScripts_folder, permissions_folder, before_migration_folder, after_migration_folder, change_drop_folder); }
public static void build_the_container(ConfigurationPropertyHolder configuration_property_holder) { Container.initialize_with(null); Container.initialize_with(build_items_for_container(configuration_property_holder)); initialize_file_log_appender(); set_logging_level_debug_when_debug(configuration_property_holder); }
private static InversionContainer build_items_for_container(ConfigurationPropertyHolder configuration_property_holder) { configuration_property_holder.DatabaseType = DatabaseTypeSynonyms.convert_database_type_synonyms(configuration_property_holder.DatabaseType); set_up_current_mappings(configuration_property_holder); Logger multiLogger = GetMultiLogger(configuration_property_holder); var container = new StructureMap.Container(cfg => { cfg.For <ConfigurationPropertyHolder>().Singleton().Use(configuration_property_holder); cfg.For <FileSystemAccess>().Singleton().Use(context => new DotNetFileSystemAccess(configuration_property_holder)); cfg.For <Database>().Singleton().Use(context => DatabaseBuilder.build(context.GetInstance <FileSystemAccess>(), configuration_property_holder)); cfg.For <KnownFolders>().Singleton().Use(context => KnownFoldersBuilder.build(context.GetInstance <FileSystemAccess>(), configuration_property_holder)); cfg.For <LogFactory>().Singleton().Use <MultipleLoggerLogFactory>(); //cfg.For<Logger>().Singleton().Use(context => LogBuilder.build(context.GetInstance<FileSystemAccess>(), configuration_property_holder)); cfg.For <Logger>().Use(multiLogger); cfg.For <CryptographicService>().Singleton().Use <MD5CryptographicService>(); cfg.For <DatabaseMigrator>().Singleton().Use(context => new DefaultDatabaseMigrator(context.GetInstance <Database>(), context.GetInstance <CryptographicService>(), configuration_property_holder)); cfg.For <VersionResolver>().Singleton().Use( context => VersionResolverBuilder.build(context.GetInstance <FileSystemAccess>(), configuration_property_holder)); cfg.For <EnvironmentSet>().Singleton().Use(new DefaultEnvironmentSet(configuration_property_holder)); cfg.For <Initializer>().Singleton().Use <FileSystemInitializer>(); }); // forcing a build of database to initialize connections so we can be sure server/database have values Database database = container.GetInstance <Database>(); database.initialize_connections(configuration_property_holder); configuration_property_holder.ServerName = database.server_name; configuration_property_holder.DatabaseName = database.database_name; configuration_property_holder.ConnectionString = database.connection_string; return(new StructureMapContainer(container)); }
public static bool in_interactive_mode(ConfigurationPropertyHolder configuration_property_holder) { if (Environment.UserInteractive && !configuration_property_holder.Silent) { return(true); } return(false); }
public DefaultEnvironmentSet(ConfigurationPropertyHolder configuration_property_holder) { set_items = configuration_property_holder.EnvironmentNames .Split(',') .Where(x => !string.IsNullOrWhiteSpace(x)) .Select(x => new DefaultEnvironment(x.Trim())) .ToList(); }
private static void set_up_current_mappings(ConfigurationPropertyHolder configuration_property_holder) { ApplicationParameters.CurrentMappings.roundhouse_schema_name = configuration_property_holder.SchemaName; ApplicationParameters.CurrentMappings.version_table_name = configuration_property_holder.VersionTableName; ApplicationParameters.CurrentMappings.scripts_run_table_name = configuration_property_holder.ScriptsRunTableName; ApplicationParameters.CurrentMappings.scripts_run_errors_table_name = configuration_property_holder.ScriptsRunErrorsTableName; ApplicationParameters.CurrentMappings.database_type = configuration_property_holder.DatabaseType; }
public DefaultEnvironmentSet(ConfigurationPropertyHolder configuration_property_holder) { set_items = configuration_property_holder.EnvironmentNames .Split(',') .Where(x => !string.IsNullOrWhiteSpace(x)) .Select(x => new DefaultEnvironment(x.Trim())) .ToList(); }
private static void delete_database() { ConfigurationPropertyHolder configuration_property_holder = migrator.GetConfiguration(); ApplicationConfiguraton.set_defaults_if_properties_are_not_set(configuration_property_holder); db.configuration = configuration_property_holder; db.delete_database_if_it_exists(); }
public MSBuildLogger(ConfigurationPropertyHolder configuration) { if (configuration.MSBuildTask != null) { build_engine = configuration.MSBuildTask.BuildEngine; } calling_task = configuration; }
private static void WriteStartupParameters(ITeamCityWriter logger, ConfigurationPropertyHolder config) { using (var l = logger.OpenBlock("startup parameters")) { l.WriteMessage($"ServerName: {config.ServerName}"); l.WriteMessage($"DatabaseName: {config.DatabaseName}"); l.WriteMessage($"ConnectionString: {config.ConnectionString}"); l.WriteMessage($"ConnectionStringAdmin: {config.ConnectionStringAdmin}"); l.WriteMessage($"CommandTimeout: {config.CommandTimeout}"); l.WriteMessage($"CommandTimeoutAdmin: {config.CommandTimeoutAdmin}"); l.WriteMessage($"SqlFilesDirectory: {config.SqlFilesDirectory}"); l.WriteMessage($"RepositoryPath: {config.RepositoryPath}"); //l.WriteMessage($"Version: {config.Version}"); l.WriteMessage($"VersionFile: {config.VersionFile}"); l.WriteMessage($"VersionXPath: {config.VersionXPath}"); l.WriteMessage($"AlterDatabaseFolderName: {config.AlterDatabaseFolderName}"); l.WriteMessage($"RunAfterCreateDatabaseFolderName: {config.RunAfterCreateDatabaseFolderName}"); l.WriteMessage($"RunBeforeUpFolderName: {config.RunBeforeUpFolderName}"); l.WriteMessage($"UpFolderName: {config.UpFolderName}"); l.WriteMessage($"DownFolderName: {config.DownFolderName}"); l.WriteMessage($"RunFirstAfterUpFolderName: {config.RunFirstAfterUpFolderName}"); l.WriteMessage($"FunctionsFolderName: {config.FunctionsFolderName}"); l.WriteMessage($"ViewsFolderName: {config.ViewsFolderName}"); l.WriteMessage($"SprocsFolderName: {config.SprocsFolderName}"); l.WriteMessage($"IndexesFolderName: {config.IndexesFolderName}"); l.WriteMessage($"RunAfterOtherAnyTimeScriptsFolderName: {config.RunAfterOtherAnyTimeScriptsFolderName}"); l.WriteMessage($"PermissionsFolderName: {config.PermissionsFolderName}"); //l.WriteMessage($"BeforeMigrationFolderName: {config.BeforeMigrationFolderName}"); l.WriteMessage($"SchemaName: {config.SchemaName}"); l.WriteMessage($"VersionTableName: {config.VersionTableName}"); l.WriteMessage($"ScriptsRunTableName: {config.ScriptsRunTableName}"); l.WriteMessage($"ScriptsRunErrorsTableName: {config.ScriptsRunErrorsTableName}"); l.WriteMessage($"EnvironmentName: {config.EnvironmentName}"); l.WriteMessage($"Restore: {config.Restore}"); l.WriteMessage($"RestoreFromPath: {config.RestoreFromPath}"); l.WriteMessage($"RestoreCustomOptions: {config.RestoreCustomOptions}"); l.WriteMessage($"RestoreTimeout: {config.RestoreTimeout}"); l.WriteMessage($"CreateDatabaseCustomScript: {config.CreateDatabaseCustomScript}"); l.WriteMessage($"OutputPath: {config.OutputPath}"); l.WriteMessage($"WarnOnOneTimeScriptChanges: {config.WarnOnOneTimeScriptChanges}"); //l.WriteMessage($"WarnAndIgnoreOnOneTimeScriptChanges: {config.WarnAndIgnoreOnOneTimeScriptChanges}"); l.WriteMessage($"Silent: {config.Silent}"); l.WriteMessage($"DatabaseType: {config.DatabaseType}"); l.WriteMessage($"Drop: {config.Drop}"); l.WriteMessage($"DoNotCreateDatabase: {config.DoNotCreateDatabase}"); l.WriteMessage($"WithTransaction: {config.WithTransaction}"); l.WriteMessage($"RecoveryMode: {config.RecoveryMode}"); l.WriteMessage($"Debug: {config.Debug}"); l.WriteMessage($"DryRun: {config.DryRun}"); l.WriteMessage($"RunAllAnyTimeScripts: {config.RunAllAnyTimeScripts}"); l.WriteMessage($"DisableTokenReplacement: {config.DisableTokenReplacement}"); l.WriteMessage( $"SearchAllSubdirectoriesInsteadOfTraverse: {config.SearchAllSubdirectoriesInsteadOfTraverse}"); l.WriteMessage($"DisableOutput: {config.DisableOutput}"); l.WriteMessage($"Logger: {config.Logger}"); } }
private static void ApplyConfig(ConfigurationPropertyHolder from, ConfigurationPropertyHolder to) { to.Logger = from.Logger; to.ServerName = from.ServerName; to.DatabaseName = from.DatabaseName; to.ConnectionString = from.ConnectionString; to.ConnectionStringAdmin = from.ConnectionStringAdmin; to.CommandTimeout = from.CommandTimeout; to.CommandTimeoutAdmin = from.CommandTimeoutAdmin; to.SqlFilesDirectory = from.SqlFilesDirectory; to.RepositoryPath = from.RepositoryPath; //to.Version = from.Version; to.VersionFile = from.VersionFile; to.VersionXPath = from.VersionXPath; to.AlterDatabaseFolderName = from.AlterDatabaseFolderName; to.RunAfterCreateDatabaseFolderName = from.RunAfterCreateDatabaseFolderName; to.RunBeforeUpFolderName = from.RunBeforeUpFolderName; to.UpFolderName = from.UpFolderName; to.DownFolderName = from.DownFolderName; to.RunFirstAfterUpFolderName = from.RunFirstAfterUpFolderName; to.FunctionsFolderName = from.FunctionsFolderName; to.ViewsFolderName = from.ViewsFolderName; to.SprocsFolderName = from.SprocsFolderName; to.IndexesFolderName = from.IndexesFolderName; to.RunAfterOtherAnyTimeScriptsFolderName = from.RunAfterOtherAnyTimeScriptsFolderName; to.PermissionsFolderName = from.PermissionsFolderName; /*to.BeforeMigrationFolderName = from.BeforeMigrationFolderName; * to.AfterMigrationFolderName = from.AfterMigrationFolderName;*/ to.SchemaName = from.SchemaName; to.VersionTableName = from.VersionTableName; to.ScriptsRunTableName = from.ScriptsRunTableName; to.ScriptsRunErrorsTableName = from.ScriptsRunErrorsTableName; to.EnvironmentName = from.EnvironmentName; to.Restore = from.Restore; to.RestoreFromPath = from.RestoreFromPath; to.RestoreCustomOptions = from.RestoreCustomOptions; to.RestoreTimeout = from.RestoreTimeout; to.CreateDatabaseCustomScript = from.CreateDatabaseCustomScript; to.OutputPath = from.OutputPath; to.WarnOnOneTimeScriptChanges = from.WarnOnOneTimeScriptChanges; //to.WarnAndIgnoreOnOneTimeScriptChanges = from.WarnAndIgnoreOnOneTimeScriptChanges; to.Silent = from.Silent; to.DatabaseType = from.DatabaseType; to.Drop = from.Drop; to.DoNotCreateDatabase = from.DoNotCreateDatabase; to.WithTransaction = from.WithTransaction; to.RecoveryMode = from.RecoveryMode; to.Debug = from.Debug; to.DryRun = from.DryRun; to.Baseline = from.Baseline; to.RunAllAnyTimeScripts = from.RunAllAnyTimeScripts; to.DisableTokenReplacement = from.DisableTokenReplacement; to.SearchAllSubdirectoriesInsteadOfTraverse = from.SearchAllSubdirectoriesInsteadOfTraverse; to.DisableOutput = from.DisableOutput; }
private static IDictionary<string, string> create_dictionary_from_configuration(ConfigurationPropertyHolder configuration) { Dictionary<string, string> property_dictionary = new Dictionary<string, string>(); foreach (var property in configuration.GetType().GetProperties()) { property_dictionary.Add(property.Name.to_lower(), property.GetValue(configuration, null).to_string()); } return property_dictionary; }
public static VersionResolver build(FileSystemAccess file_system, ConfigurationPropertyHolder configuration_property_holder) { VersionResolver xml_version_finder = new XmlFileVersionResolver(file_system, configuration_property_holder.VersionXPath, configuration_property_holder.VersionFile); VersionResolver dll_version_finder = new DllFileVersionResolver(file_system, configuration_property_holder.VersionFile); VersionResolver script_number_version_finder = new ScriptfileVersionResolver(file_system, configuration_property_holder); IEnumerable<VersionResolver> resolvers = new List<VersionResolver> { xml_version_finder, dll_version_finder, script_number_version_finder }; return new ComplexVersionResolver(resolvers); }
private static RoundhouseUpdateCheckRunner get_update_check_runner(ConfigurationPropertyHolder configuration, RoundhouseMigrationRunner migration_runner) { return(new RoundhouseUpdateCheckRunner( Container.get_an_instance_of <environments.EnvironmentSet>(), Container.get_an_instance_of <KnownFolders>(), Container.get_an_instance_of <FileSystemAccess>(), Container.get_an_instance_of <DatabaseMigrator>(), configuration, migration_runner)); }
public MSBuildLogger(ConfigurationPropertyHolder configuration) { var task = configuration as ITask; if (task != null) { build_engine = task.BuildEngine; } calling_task = configuration; }
public override void initialize_connections(ConfigurationPropertyHolder configuration_property_holder) { if (!string.IsNullOrEmpty(connection_string)) { string[] parts = connection_string.Split(';'); foreach (string part in parts) { if (string.IsNullOrEmpty(server_name) && (part.to_lower().Contains("server") || part.to_lower().Contains("data source"))) { server_name = part.Substring(part.IndexOf("=") + 1); } if (string.IsNullOrEmpty(database_name) && (part.to_lower().Contains("initial catalog") || part.to_lower().Contains("database"))) { database_name = part.Substring(part.IndexOf("=") + 1); } } if (!connection_string.to_lower().Contains(connect_options.to_lower())) { connect_options = string.Empty; foreach (string part in parts) { if (!part.to_lower().Contains("server") && !part.to_lower().Contains("data source") && !part.to_lower().Contains("initial catalog") && !part.to_lower().Contains("database")) { connect_options += part + ";"; } } } } if (connect_options == "Integrated Security") { connect_options = "Integrated Security=SSPI;"; } if (string.IsNullOrEmpty(connection_string)) { connection_string = build_connection_string(server_name, database_name, connect_options); } configuration_property_holder.ConnectionString = connection_string; set_provider(); if (string.IsNullOrEmpty(admin_connection_string)) { admin_connection_string = Regex.Replace(connection_string, "initial catalog=.*?;", "initial catalog=master;", RegexOptions.IgnoreCase); admin_connection_string = Regex.Replace(admin_connection_string, "database=.*?;", "database=master;", RegexOptions.IgnoreCase); } configuration_property_holder.ConnectionStringAdmin = admin_connection_string; //set_repository(configuration_property_holder); }
public override void initialize_connections(ConfigurationPropertyHolder configuration_property_holder) { if (!string.IsNullOrEmpty(connection_string)) { string[] parts = connection_string.Split(';'); foreach (string part in parts) { if (string.IsNullOrEmpty(server_name) && (part.to_lower().Contains("server") || part.to_lower().Contains("data source"))) { server_name = part.Substring(part.IndexOf("=") + 1); } if (string.IsNullOrEmpty(database_name) && (part.to_lower().Contains("initial catalog") || part.to_lower().Contains("database"))) { database_name = part.Substring(part.IndexOf("=") + 1); } } if (!connection_string.to_lower().Contains(connect_options.to_lower())) { connect_options = string.Empty; foreach (string part in parts) { if (!part.to_lower().Contains("server") && !part.to_lower().Contains("data source") && !part.to_lower().Contains("initial catalog") && !part.to_lower().Contains("database")) { connect_options += part + ";"; } } } } if (connect_options == "Integrated Security") { connect_options = "Integrated Security=SSPI;"; } if (string.IsNullOrEmpty(connection_string)) { connection_string = build_connection_string(server_name, database_name, connect_options); } configuration_property_holder.ConnectionString = connection_string; set_provider(); if (string.IsNullOrEmpty(admin_connection_string)) { admin_connection_string = Regex.Replace(connection_string, "initial catalog=.*?;", "initial catalog=master;", RegexOptions.IgnoreCase); admin_connection_string = Regex.Replace(admin_connection_string, "database=.*?;", "database=master;", RegexOptions.IgnoreCase); } configuration_property_holder.ConnectionStringAdmin = admin_connection_string; //set_repository(configuration_property_holder); }
public override void initialize_connections(ConfigurationPropertyHolder configuration_property_holder) { if (!string.IsNullOrEmpty(connection_string)) { // Must allow User variables for SPROCs var connectionBuilder = new MySqlConnectionStringBuilder(connection_string); if (!connectionBuilder.AllowUserVariables) { connectionBuilder.Add("Allow User Variables", "True"); connection_string = connectionBuilder.ConnectionString; } string[] parts = connection_string.Split(';'); foreach (string part in parts) { if (string.IsNullOrEmpty(server_name) && (part.to_lower().Contains("server") || part.to_lower().Contains("data source"))) { server_name = part.Substring(part.IndexOf("=") + 1); } if (string.IsNullOrEmpty(database_name) && (part.to_lower().Contains("database") || part.to_lower().Contains("database"))) { database_name = part.Substring(part.IndexOf("=") + 1); } } } if (server_name == infrastructure.ApplicationParameters.default_server_name) { server_name = "localhost"; } if (string.IsNullOrEmpty(connection_string)) { InteractivePrompt.write_header(configuration_property_holder); var user_name = InteractivePrompt.get_user("root", configuration_property_holder); var password = InteractivePrompt.get_password("root", configuration_property_holder); InteractivePrompt.write_footer(); connection_string = build_connection_string(server_name, database_name, user_name, password); } configuration_property_holder.ConnectionString = connection_string; set_provider(); if (string.IsNullOrEmpty(admin_connection_string)) { var builder = new MySqlConnectionStringBuilder(connection_string); builder.Database = "information_schema"; admin_connection_string = builder.ConnectionString; } configuration_property_holder.ServerName = server_name; configuration_property_holder.DatabaseName = database_name; configuration_property_holder.ConnectionStringAdmin = admin_connection_string; }
public MSBuildLogger(ConfigurationPropertyHolder configuration) { var task = configuration as ITask; if (task != null) { build_engine = task.BuildEngine; } calling_task = configuration; }
public override void Context() { configuration = new DefaultConfiguration { UserTokens = new Dictionary <string, string>() { { "UserId", "123" }, { "UserName", "Some Name" } } }; }
public static void run_migrator(ConfigurationPropertyHolder configuration) { RoundhouseMigrationRunner migration_runner = get_migration_runner(configuration); migration_runner.run(); if (!configuration.Silent) { Console.WriteLine("{0}Please press enter to continue...", Environment.NewLine); Console.Read(); } }
private static Logger GetMultiLogger(ConfigurationPropertyHolder configuration_property_holder) { IList <Logger> loggers = new List <Logger>(); if (configuration_property_holder.Logger != null && !loggers.Contains(configuration_property_holder.Logger)) { loggers.Add(configuration_property_holder.Logger); } return(new MultipleLogger(loggers)); }
public DefaultDatabaseMigrator(Database database, CryptographicService crypto_provider, ConfigurationPropertyHolder configuration) { this.database = database; this.crypto_provider = crypto_provider; this.configuration = configuration; restoring_database = configuration.Restore; restore_path = configuration.RestoreFromPath; custom_restore_options = configuration.RestoreCustomOptions; output_path = configuration.OutputPath; error_on_one_time_script_changes = !configuration.WarnOnOneTimeScriptChanges; is_running_all_any_time_scripts = configuration.RunAllAnyTimeScripts; }
public static VersionResolver build(FileSystemAccess file_system, ConfigurationPropertyHolder configuration_property_holder) { VersionResolver xml_version_finder = new XmlFileVersionResolver(file_system, configuration_property_holder.VersionXPath, configuration_property_holder.VersionFile); VersionResolver dll_version_finder = new DllFileVersionResolver(file_system, configuration_property_holder.VersionFile); VersionResolver script_number_version_finder = new ScriptfileVersionResolver(file_system, configuration_property_holder); IEnumerable <VersionResolver> resolvers = new List <VersionResolver> { xml_version_finder, dll_version_finder, script_number_version_finder }; return(new ComplexVersionResolver(resolvers)); }
public DefaultDatabaseMigrator(Database database, CryptographicService crypto_provider, ConfigurationPropertyHolder configuration) { this.database = database; this.crypto_provider = crypto_provider; this.configuration = configuration; restoring_database = configuration.Restore; restore_path = configuration.RestoreFromPath; custom_restore_options = configuration.RestoreCustomOptions; output_path = configuration.OutputPath; error_on_one_time_script_changes = !configuration.WarnOnOneTimeScriptChanges; is_running_all_any_time_scripts = configuration.RunAllAnyTimeScripts; }
// initial database setup private void run_initial_database_setup(Migrate migrator, ConfigurationPropertyHolder configuration, Assembly mappings_assembly, Assembly conventions_assembly) { var files_directory = configuration.SqlFilesDirectory; configuration.SqlFilesDirectory = "."; migrator.Run(); generate_database_schema(configuration.DatabaseName, mappings_assembly, conventions_assembly); configuration.SqlFilesDirectory = files_directory; migrator.RunDropCreate(); }
public override void initialize_connections(ConfigurationPropertyHolder configuration_property_holder) { if (!string.IsNullOrEmpty(connection_string)) { string[] parts = connection_string.Split(';'); foreach (string part in parts) { if (string.IsNullOrEmpty(server_name) && part.to_lower().Contains("server")) { server_name = part.Substring(part.IndexOf("=") + 1); } if (string.IsNullOrEmpty(database_name) && part.to_lower().Contains("database")) { database_name = part.Substring(part.IndexOf("=") + 1); } } if (!connection_string.to_lower().Contains(connect_options.to_lower())) { connect_options = string.Empty; foreach (string part in parts) { if (!part.to_lower().Contains("server") && !part.to_lower().Contains("data source") && !part.to_lower().Contains("initial catalog") && !part.to_lower().Contains("database")) { connect_options += part + ";"; } } } } if (connect_options == "Trusted_Connection") { connect_options = "Trusted_Connection=yes;"; } if (string.IsNullOrEmpty(connection_string)) { connection_string = build_connection_string(server_name, database_name, connect_options); } if (connection_string.to_lower().Contains("sqlserver") || connection_string.to_lower().Contains("sqlncli")) { connection_string = build_connection_string(server_name, database_name, connect_options); } configuration_property_holder.ConnectionString = connection_string; set_provider(); admin_connection_string = connection_string; configuration_property_holder.ConnectionStringAdmin = admin_connection_string; //set_repository(configuration_property_holder); }
public static void run_migrator(ConfigurationPropertyHolder configuration) { RoundhouseMigrationRunner migration_runner = get_migration_runner(configuration); migration_runner.run(); if (!configuration.Silent) { Console.WriteLine("{0}Please press enter to continue...", Environment.NewLine); Console.Read(); } }
public override void initialize_connections(ConfigurationPropertyHolder configuration_property_holder) { if (!string.IsNullOrEmpty(connection_string)) { string[] parts = connection_string.Split(';'); foreach (string part in parts) { if (string.IsNullOrEmpty(server_name) && part.to_lower().Contains("server")) { server_name = part.Substring(part.IndexOf("=") + 1); } if (string.IsNullOrEmpty(database_name) && part.to_lower().Contains("database")) { database_name = part.Substring(part.IndexOf("=") + 1); } } if (!connection_string.to_lower().Contains(connect_options.to_lower())) { connect_options = string.Empty; foreach (string part in parts) { if (!part.to_lower().Contains("server") && !part.to_lower().Contains("data source") && !part.to_lower().Contains("initial catalog") && !part.to_lower().Contains("database")) { connect_options += part + ";"; } } } } if (connect_options == "Trusted_Connection") { connect_options = "Trusted_Connection=yes;"; } if (string.IsNullOrEmpty(connection_string)) { connection_string = build_connection_string(server_name, database_name, connect_options); } if (connection_string.to_lower().Contains("sqlserver") || connection_string.to_lower().Contains("sqlncli")) { connection_string = build_connection_string(server_name, database_name, connect_options); } configuration_property_holder.ConnectionString = connection_string; set_provider(); admin_connection_string = connection_string; configuration_property_holder.ConnectionStringAdmin = admin_connection_string; //set_repository(configuration_property_holder); }
public static Database build(FileSystemAccess file_system, ConfigurationPropertyHolder configuration_property_holder) { Database database_to_migrate; if (Assembly.GetExecutingAssembly().Location.Contains("roundhouse.dll")) { merge_assembly_name = "roundhouse"; } try { string database_type = configuration_property_holder.DatabaseType; database_type = database_type.Substring(0, database_type.IndexOf(',')); database_to_migrate = DefaultInstanceCreator.create_object_from_string_type<Database>(database_type + ", " + merge_assembly_name); } catch (NullReferenceException) { database_to_migrate = DefaultInstanceCreator.create_object_from_string_type<Database>(configuration_property_holder.DatabaseType); } if (restore_from_file_ends_with_LiteSpeed_extension(file_system, configuration_property_holder.RestoreFromPath)) { database_to_migrate = new SqlServerLiteSpeedDatabase(database_to_migrate); } if (configuration_property_holder.Baseline) { database_to_migrate = new BaselineModeDatabase(database_to_migrate); } if (configuration_property_holder.DryRun) { database_to_migrate = new DryRunDatabase(database_to_migrate); } database_to_migrate.configuration = configuration_property_holder; database_to_migrate.server_name = configuration_property_holder.ServerName ?? string.Empty; database_to_migrate.database_name = configuration_property_holder.DatabaseName ?? string.Empty; database_to_migrate.connection_string = configuration_property_holder.ConnectionString; database_to_migrate.admin_connection_string = configuration_property_holder.ConnectionStringAdmin; database_to_migrate.roundhouse_schema_name = configuration_property_holder.SchemaName; database_to_migrate.version_table_name = configuration_property_holder.VersionTableName; database_to_migrate.scripts_run_table_name = configuration_property_holder.ScriptsRunTableName; database_to_migrate.scripts_run_errors_table_name = configuration_property_holder.ScriptsRunErrorsTableName; database_to_migrate.user_name = get_identity_of_person_running_roundhouse(); database_to_migrate.command_timeout = configuration_property_holder.CommandTimeout; database_to_migrate.admin_command_timeout = configuration_property_holder.CommandTimeoutAdmin; database_to_migrate.restore_timeout = configuration_property_holder.RestoreTimeout; return database_to_migrate; }
public static string get_user(string default_user_name, ConfigurationPropertyHolder configuration_property_holder) { var user_name = string.Empty; if (in_interactive_mode(configuration_property_holder)) { Console.WriteLine("Please enter a user name and press enter (leave empty for '{0}')", default_user_name); user_name = Console.ReadLine(); } user_name = !string.IsNullOrEmpty(user_name) ? user_name : default_user_name; Log.bound_to(typeof(InteractivePrompt)).log_an_info_event_containing("Using '{0}' for the user name.", user_name); return user_name; }
public override void initialize_connections(ConfigurationPropertyHolder configuration_property_holder) { if (!string.IsNullOrEmpty(connection_string)) { string[] parts = connection_string.Split(';'); foreach (string part in parts) { if (string.IsNullOrEmpty(server_name) && part.to_lower().Contains("data source")) { database_name = part.Substring(part.IndexOf("=") + 1); } //if (string.IsNullOrEmpty(database_name) && (part.to_lower().Contains("user id"))) //{ // database_name = part.Substring(part.IndexOf("=") + 1); //} } if (!connection_string.to_lower().Contains(connect_options.to_lower())) { connect_options = string.Empty; foreach (string part in parts) { if (!part.to_lower().Contains("data source")) { connect_options += part + ";"; } } } } if (connect_options == "Integrated Security") { connect_options = "Integrated Security=yes;"; } if (string.IsNullOrEmpty(connection_string)) { connection_string = build_connection_string(database_name, connect_options); } configuration_property_holder.ConnectionString = connection_string; set_provider(); if (string.IsNullOrEmpty(admin_connection_string)) { admin_connection_string = Regex.Replace(connection_string, "Integrated Security=.*?;", "Integrated Security=yes;"); admin_connection_string = Regex.Replace(admin_connection_string, "User Id=.*?;", string.Empty); admin_connection_string = Regex.Replace(admin_connection_string, "Password=.*?;", string.Empty); } configuration_property_holder.ConnectionStringAdmin = admin_connection_string; }
public override void initialize_connections(ConfigurationPropertyHolder configuration_property_holder) { if (!string.IsNullOrEmpty(connection_string)) { var parts = connection_string.Split(';'); foreach (var part in parts) { if (string.IsNullOrEmpty(server_name) && (part.to_lower().Contains("server") || part.to_lower().Contains("data source"))) { server_name = part.Substring(part.IndexOf("=") + 1); } if (string.IsNullOrEmpty(database_name) && (part.to_lower().Contains("database") || part.to_lower().Contains("database"))) { database_name = part.Substring(part.IndexOf("=") + 1); } } } server_name = server_name.to_lower(); database_name = database_name.to_lower(); configuration_property_holder.ServerName = server_name; configuration_property_holder.DatabaseName = database_name; if (server_name == infrastructure.ApplicationParameters.default_server_name) { server_name = "localhost"; } if (string.IsNullOrEmpty(connection_string)) { InteractivePrompt.write_header(configuration_property_holder); var user_name = InteractivePrompt.get_user("postgres", configuration_property_holder); var password = InteractivePrompt.get_password("postgres", configuration_property_holder); InteractivePrompt.write_footer(); connection_string = build_connection_string(server_name, database_name, user_name, password); } configuration_property_holder.ConnectionString = connection_string; set_provider(); if (string.IsNullOrEmpty(admin_connection_string)) { admin_connection_string = Regex.Replace(connection_string, "database=.*?;", "database=postgres;", RegexOptions.IgnoreCase); } configuration_property_holder.ConnectionStringAdmin = admin_connection_string; }
private static RoundhouseMigrationRunner get_migration_runner(ConfigurationPropertyHolder configuration) { return new RoundhouseMigrationRunner( configuration.RepositoryPath, Container.get_an_instance_of<environments.Environment>(), Container.get_an_instance_of<KnownFolders>(), Container.get_an_instance_of<FileSystemAccess>(), Container.get_an_instance_of<DatabaseMigrator>(), Container.get_an_instance_of<VersionResolver>(), configuration.Silent, configuration.Drop, configuration.DoNotCreateDatabase, configuration.WithTransaction, configuration.RecoveryModeSimple, configuration); }
public void Initialize(ConfigurationPropertyHolder properties, string path) { makeDir(_knownFolders.alter_database); makeDir(_knownFolders.change_drop); makeDir(_knownFolders.down); makeDir(_knownFolders.functions); makeDir(_knownFolders.indexes); makeDir(_knownFolders.permissions); makeDir(_knownFolders.run_after_create_database); makeDir(_knownFolders.run_after_other_any_time_scripts); makeDir(_knownFolders.run_before_up); makeDir(_knownFolders.run_first_after_up); makeDir(_knownFolders.sprocs); makeDir(_knownFolders.up); makeDir(_knownFolders.views); }
public override void initialize_connections(ConfigurationPropertyHolder configuration_property_holder) { if (!string.IsNullOrEmpty(connection_string)) { string[] parts = connection_string.Split(';'); foreach (string part in parts) { if (string.IsNullOrEmpty(server_name) && (part.to_lower().Contains("server") || part.to_lower().Contains("data source"))) { server_name = part.Substring(part.IndexOf("=") + 1); } if (string.IsNullOrEmpty(database_name) && (part.to_lower().Contains("database") || part.to_lower().Contains("database"))) { database_name = part.Substring(part.IndexOf("=") + 1); } } } if (server_name == infrastructure.ApplicationParameters.default_server_name) { server_name = "localhost"; } if (string.IsNullOrEmpty(connection_string)) { InteractivePrompt.write_header(configuration_property_holder); var user_name = InteractivePrompt.get_user("root", configuration_property_holder); var password = InteractivePrompt.get_password("root", configuration_property_holder); InteractivePrompt.write_footer(); connection_string = build_connection_string(server_name, database_name, user_name, password); } configuration_property_holder.ConnectionString = connection_string; set_provider(); if (string.IsNullOrEmpty(admin_connection_string)) { var builder = new MySqlConnectionStringBuilder(connection_string); builder.Database = "information_schema"; admin_connection_string = builder.ConnectionString; } configuration_property_holder.DatabaseName = database_name; configuration_property_holder.ConnectionStringAdmin = admin_connection_string; }
public override void initialize_connections(ConfigurationPropertyHolder configuration_property_holder) { // IMO in this method SqlServerDatabase and OracleDatabase implementations has unmaintainable code, // I'm not sure that DbConnectionStringBuilder could be useful here but I will just skip all parsing code. // The main goal of pasing is to get full connection string and put it into configuration_property_holder.ConnectionString. configuration_property_holder.ConnectionString = connection_string; set_provider(); if (string.IsNullOrEmpty(admin_connection_string)) { var builder = new MySqlConnectionStringBuilder(connection_string); builder.Database = "information_schema"; admin_connection_string = builder.ConnectionString; } // TODO: Initialize configuration/system.data/DbProviderFactories app.config section in code. }
public static string get_password(string default_password, ConfigurationPropertyHolder configuration_property_holder) { string password = string.Empty; if (in_interactive_mode(configuration_property_holder)) { Console.WriteLine("Please enter a password and press enter (leave empty for '{0}')", default_password); //http://www.c-sharpcorner.com/Forums/Thread/32102/ ConsoleKeyInfo info = Console.ReadKey(true); while (info.Key != ConsoleKey.Enter) { if (info.Key != ConsoleKey.Backspace) { Console.Write("*"); password += info.KeyChar; info = Console.ReadKey(true); } else if (info.Key == ConsoleKey.Backspace) { if (!string.IsNullOrEmpty(password)) { password = password.Substring(0, password.Length - 1); // get the location of the cursor int pos = Console.CursorLeft; // move the cursor to the left by one character Console.SetCursorPosition(pos - 1, Console.CursorTop); // replace it with space Console.Write(" "); // move the cursor to the left by one character again Console.SetCursorPosition(pos - 1, Console.CursorTop); } info = Console.ReadKey(true); } } for (int i = 0; i < password.Length; i++) Console.Write("*"); } Console.WriteLine(); password = !string.IsNullOrEmpty(password) ? password : default_password; Log.bound_to(typeof(InteractivePrompt)).log_an_info_event_containing("Using '*******' for the password. When YOU type hunter2, it shows to us as '*******'. ;-)"); return password; }
public static VersionResolver build(FileSystemAccess file_system, ConfigurationPropertyHolder configuration_property_holder) { VersionResolver commandLine_version_finder = new CommandLineVersionResolver(configuration_property_holder.Version); if (commandLine_version_finder.meets_criteria()) { return commandLine_version_finder; } else { VersionResolver xml_version_finder = new XmlFileVersionResolver(file_system, configuration_property_holder.VersionXPath, configuration_property_holder.VersionFile); VersionResolver dll_version_finder = new DllFileVersionResolver(file_system, configuration_property_holder.VersionFile); VersionResolver text_version_finder = new TextVersionResolver(file_system, configuration_property_holder.VersionFile); VersionResolver script_number_version_finder = new ScriptfileVersionResolver(file_system, configuration_property_holder); IEnumerable<VersionResolver> resolvers = new List<VersionResolver> { xml_version_finder, dll_version_finder, text_version_finder, script_number_version_finder }; return new ComplexVersionResolver(resolvers); } }
//todo: sqlite - does splitting batch statements apply to sqlite? //public override bool split_batch_statements //{ // get { return false; } // set // { // throw new Exception( // "This option can not be changed because SQLite database migrator always splits batch statements by using SQLiteScript class from SQLite ADO.NET provider"); // } //} public override void initialize_connections(ConfigurationPropertyHolder configuration_property_holder) { server_name = "sqlite"; if (!string.IsNullOrEmpty(connection_string)) { string[] parts = connection_string.Split(';'); foreach (string part in parts) { if (string.IsNullOrEmpty(server_name) && part.to_lower().Contains("data source")) { database_name = part.Substring(part.IndexOf("=") + 1); } } } if (database_name.to_lower() != ":memory:" && !database_name.to_lower().EndsWith(".db3")) { database_name = database_name + ".db3"; } if (string.IsNullOrEmpty(connection_string)) { connection_string = build_connection_string(database_name); } configuration_property_holder.ConnectionString = connection_string; if (string.IsNullOrEmpty(admin_connection_string)) { admin_connection_string = connection_string; } configuration_property_holder.DatabaseName = database_name; configuration_property_holder.ConnectionStringAdmin = admin_connection_string; sqlite_ado_net_provider_resolver.output_path = configuration_property_holder.OutputPath; set_provider(); }
public override void initialize_connections(ConfigurationPropertyHolder configuration_property_holder) { if (!string.IsNullOrEmpty(connection_string)) { var connection_string_builder = new SqlConnectionStringBuilder(connection_string); server_name = connection_string_builder.DataSource; database_name = connection_string_builder.InitialCatalog; } if (string.IsNullOrEmpty(connection_string)) { connection_string = build_connection_string(server_name, database_name, connect_options); } configuration_property_holder.ConnectionString = connection_string; set_provider(); if (string.IsNullOrEmpty(admin_connection_string)) { admin_connection_string = Regex.Replace(connection_string, "initial catalog=.*?;", "initial catalog=master;", RegexOptions.IgnoreCase); admin_connection_string = Regex.Replace(admin_connection_string, "database=.*?;", "database=master;", RegexOptions.IgnoreCase); } configuration_property_holder.ConnectionStringAdmin = admin_connection_string; }