class Arrival::AlterArgument
Represents the '–alter' argument of Percona's pt-online-schema-change See www.percona.com/doc/percona-toolkit/2.0/pt-online-schema-change.html
Constants
- ALTER_TABLE_REGEX
Attributes
statement[R]
table_name[R]
Public Class Methods
new(statement)
click to toggle source
Constructor
@param statement [String] @raise [InvalidAlterStatement] if the statement is not an ALTER TABLE
# File lib/arrival/alter_argument.rb, line 15 def initialize(statement) @statement = statement match = statement.match(ALTER_TABLE_REGEX) raise InvalidAlterStatement unless match @table_name = match.captures[0] end
Public Instance Methods
to_s()
click to toggle source
Returns the '–alter' pt-online-schema-change argument as a string. See www.percona.com/doc/percona-toolkit/2.0/pt-online-schema-change.html
# File lib/arrival/alter_argument.rb, line 26 def to_s "--alter \"#{parsed_statement}\"" end
Private Instance Methods
parsed_statement()
click to toggle source
Removes the 'ALTER TABLE' portion of the SQL statement
@return [String]
# File lib/arrival/alter_argument.rb, line 37 def parsed_statement @parsed_statement ||= statement .gsub(ALTER_TABLE_REGEX, '') .gsub('`', '\\\`') end