public int RunEraseOption(EraseOption opts) { try { //parse tokens var platform = _configurationService.GetValueOrDefault(opts.Platform, ENVIRONMENT_VARIABLE.YUNIQL_PLATFORM, defaultValue: SUPPORTED_DATABASES.SQLSERVER); var tokens = opts.Tokens.Select(t => new KeyValuePair <string, string>(t.Split("=")[0], t.Split("=")[1])).ToList(); var configuration = Configuration.Instance; configuration.Workspace = opts.Workspace; configuration.IsDebug = opts.IsDebug; configuration.Platform = platform; configuration.ConnectionString = opts.ConnectionString; configuration.CommandTimeout = opts.CommandTimeout; configuration.Tokens = tokens; configuration.IsForced = opts.Force; configuration.Environment = opts.Environment; //run all erase scripts var migrationService = _migrationServiceFactory.Create(platform); migrationService.Erase(); _traceService.Success($"Schema erase completed successfuly on {configuration.Workspace}."); return(0); } catch (Exception ex) { return(OnException(ex, "Failed to execute erase function", opts.IsDebug)); } }
public int RunEraseOption(EraseOption opts) { try { //parse tokens var platform = _configurationService.GetValueOrDefault(opts.Platform, ENVIRONMENT_VARIABLE.YUNIQL_PLATFORM, defaultValue: SUPPORTED_DATABASES.SQLSERVER); var tokens = opts.Tokens.Select(t => new KeyValuePair <string, string>(t.Split("=")[0], t.Split("=")[1])).ToList(); if (!string.IsNullOrEmpty(opts.MetaSchemaName)) { tokens.Add(new KeyValuePair <string, string>(RESERVED_TOKENS.YUNIQL_SCHEMA_NAME, opts.MetaSchemaName)); } if (!string.IsNullOrEmpty(opts.MetaTableName)) { tokens.Add(new KeyValuePair <string, string>(RESERVED_TOKENS.YUNIQL_TABLE_NAME, opts.MetaTableName)); } tokens.AddRange(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>(RESERVED_TOKENS.YUNIQL_APPLIED_BY_TOOL, "yuniql-cli"), new KeyValuePair <string, string>(RESERVED_TOKENS.YUNIQL_APPLIED_BY_TOOL_VERSION, this.GetType().Assembly.GetName().Version.ToString()) }); var configuration = Configuration.Instance; configuration.Workspace = opts.Workspace; configuration.IsDebug = opts.IsDebug; configuration.Platform = platform; configuration.ConnectionString = opts.ConnectionString; configuration.CommandTimeout = opts.CommandTimeout; configuration.Tokens = tokens; configuration.IsForced = opts.Force; configuration.Environment = opts.Environment; configuration.MetaSchemaName = opts.MetaSchemaName; configuration.MetaTableName = opts.MetaTableName; //run all erase scripts var migrationService = _migrationServiceFactory.Create(platform); migrationService.Erase(); _traceService.Success($"Schema erase completed successfuly on {configuration.Workspace}."); return(0); } catch (Exception ex) { return(OnException(ex, "Failed to execute erase function", opts.IsDebug)); } }
public int RunEraseOption(EraseOption opts) { try { //if no path provided, we default into current directory if (string.IsNullOrEmpty(opts.Path)) { var workingPath = _environmentService.GetCurrentDirectory(); opts.Path = workingPath; } //if no connection string provided, we default into environment variable or throw exception if (string.IsNullOrEmpty(opts.ConnectionString)) { opts.ConnectionString = _environmentService.GetEnvironmentVariable(ENVIRONMENT_VARIABLE.YUNIQL_CONNECTION_STRING); } //if no target platform provided, we default into sqlserver if (string.IsNullOrEmpty(opts.Platform)) { opts.Platform = _environmentService.GetEnvironmentVariable(ENVIRONMENT_VARIABLE.YUNIQL_TARGET_PLATFORM); if (string.IsNullOrEmpty(opts.Platform)) { opts.Platform = SUPPORTED_DATABASES.SQLSERVER; } } //parse tokens var tokens = opts.Tokens .Select(t => new KeyValuePair <string, string>(t.Split("=")[0], t.Split("=")[1])) .ToList(); //run all erase scripts var migrationService = _migrationServiceFactory.Create(opts.Platform); migrationService.Initialize(opts.ConnectionString, opts.CommandTimeout); migrationService.Erase(opts.Path, tokens, opts.CommandTimeout, opts.Environment); _traceService.Success($"Schema erase completed successfuly on {opts.Path}."); return(0); } catch (Exception ex) { return(OnException(ex, "Failed to execute erase function", opts.Debug, _traceService)); } }