class Arrival::CliGenerator
Generates the equivalent Percona's pt-online-schema-change command to the given SQL statement
–no-check-alter is used to allow running CHANGE COLUMN statements. For more details, check: www.percona.com/doc/percona-toolkit/2.2/pt-online-schema-change.html#cmdoption-pt-online-schema-change–[no]check-alter # rubocop:disable Metrics/LineLength
Constants
- COMMAND_NAME
- DEFAULT_OPTIONS
Attributes
Public Instance Methods
Generates the percona command. Fills all the connection credentials from the current AR connection, but that can be amended via ENV-vars: PERCONA_DB_HOST, PERCONA_DB_USER, PERCONA_DB_PASSWORD, PERCONA_DB_NAME Table name can't not be amended, it populates automatically from the migration data
deprecated: @param table_name [String] @param statement [String] MySQL statement @return [String]
# File lib/arrival/cli_generator.rb, line 51 def generate(_table_name=nil, statement) alter_argument = AlterArgument.new(statement) "#{command} #{all_options} #{alter_argument} #{Option.new("table", alter_argument.table_name)}" end
Generates the percona command for a raw MySQL statement. Fills all the connection credentials from the current AR connection, but that can amended via ENV-vars: PERCONA_DB_HOST, PERCONA_DB_USER, PERCONA_DB_PASSWORD, PERCONA_DB_NAME Table name can't not be amended, it populates automatically from the migration data
@param statement [String] MySQL statement @return [String]
# File lib/arrival/cli_generator.rb, line 65 def parse_statement(statement) alter_argument = AlterArgument.new(statement) # dsn = DSN.new(connection_details.database, alter_argument.table_name) "#{command} #{all_options} #{alter_argument} #{Option.new("table", alter_argument.table_name)}" end
Private Instance Methods
Returns all the arguments to execute pt-online-schema-change with
@return [String]
# File lib/arrival/cli_generator.rb, line 83 def all_options env_variable_options = UserOptions.new global_configuration_options = UserOptions.new(Arrival.configuration.global_arrival_args) options = env_variable_options.merge(global_configuration_options).merge(DEFAULT_OPTIONS) options.to_a.join(' ') end
# File lib/arrival/cli_generator.rb, line 76 def command "#{COMMAND_NAME} #{connection_details}" end