private readonly Dictionary <string, string> _scriptReplacements = new Dictionary <string, string>(); // Holds tokens and replacement values for scripts public dbmgrDataMigration(IDatabaseConfiguration config, string deployDirectory, IDBScripts database, string scriptReplacementsFile, string[] replacementParameters, string netConnectionString = null) { // Setup data context information _database = database; if (netConnectionString != null) { _connectionString = netConnectionString; } else { _connectionString = config.ConnectionString; _connectionString = DataContext.GetConnectionString(_connectionString, replacementParameters); } _providerName = config.ConnectionProviderName; _defaultTimeout = config.DefaultCommandTimeoutSecs; _defaultTransTimeout = config.DefaultTransactionTimeoutMins; // Setup Directories used _baseDeployDirectory = Path.Combine(deployDirectory, "Database"); _migrationScriptLocation = Path.Combine(_baseDeployDirectory, "Deltas"); _currentScriptLocation = Path.Combine(_baseDeployDirectory, "Current"); _postScriptLocation = Path.Combine(_baseDeployDirectory, "Post"); if (String.IsNullOrWhiteSpace(scriptReplacementsFile)) { scriptReplacementsFile = Path.Combine(_baseDeployDirectory, "Database", DEFAULT_SCRIPT_REPLACEMENTS_FILE); } if (File.Exists(scriptReplacementsFile)) { LoadScriptReplacements(scriptReplacementsFile); } }
private static void SetDatabaseType(dbmgrCommandLineOptions options) { // Specify the database type of either SQL Server or Oracle if (options.DatabaseType != null) { if (options.DatabaseType.Equals(new SQLServerScripts().ShortName, StringComparison.InvariantCultureIgnoreCase)) { _database = new SQLServerScripts(); Log.Logger.Debug("Database Type SQL Server specified on command line."); } else if (options.DatabaseType.Equals(new OracleScripts().ShortName, StringComparison.InvariantCultureIgnoreCase)) { _database = new OracleScripts(); Log.Logger.Debug("Database Type Oracle specified on command line."); } else { throw new NotSupportedException($"Invalid database type option selected {options.DatabaseType}"); } } if (_database == null) { Log.Logger.Information("Database Type not specified on command line; defaulting Database Type to SQL Server."); _database = new SQLServerScripts(); } }