Class: PerconaMigrator::AlterArgument

Inherits:
Object
  • Object
show all
Defined in:
lib/percona_migrator/alter_argument.rb

Overview

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

Constant Summary collapse

ALTER_TABLE_REGEX =
/\AALTER TABLE `(\w+)` /

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(statement) ⇒ AlterArgument

Constructor

Parameters:

  • statement (String)

Raises:



15
16
17
18
19
20
21
22
# File 'lib/percona_migrator/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

Instance Attribute Details

#table_nameObject (readonly)

Returns the value of attribute table_name.



9
10
11
# File 'lib/percona_migrator/alter_argument.rb', line 9

def table_name
  @table_name
end

Instance Method Details

#to_sObject

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



26
27
28
# File 'lib/percona_migrator/alter_argument.rb', line 26

def to_s
  "--alter \"#{parsed_statement}\""
end