Class: DeclareSchema::SchemaChange::TableChange

Inherits:
Base
  • Object
show all
Defined in:
lib/declare_schema/schema_change/table_change.rb

Instance Method Summary collapse

Methods inherited from Base

#down, format_options, #up

Constructor Details

#initialize(table_name, old_options, new_options) ⇒ TableChange

Returns a new instance of TableChange.

Parameters:

  • table_name (String)

    The name of the table being changed

  • old_options (Hash)

    The old/existing table option definitions

  • new_options (Hash)

    The new/existing table option definitions



12
13
14
15
16
17
18
19
# File 'lib/declare_schema/schema_change/table_change.rb', line 12

def initialize(table_name, old_options, new_options)
  old_options.is_a?(Hash) or raise ArgumentError, "old_options must be a Hash but is: #{old_options.inspect}"
  new_options.is_a?(Hash) or raise ArgumentError, "new_options must be a Hash but is: #{new_options.inspect}"

  @table_name  = table_name
  @old_options = old_options
  @new_options = new_options
end

Instance Method Details

#down_commandObject



25
26
27
# File 'lib/declare_schema/schema_change/table_change.rb', line 25

def down_command
  alter_table(@table_name, @old_options)
end

#up_commandObject



21
22
23
# File 'lib/declare_schema/schema_change/table_change.rb', line 21

def up_command
  alter_table(@table_name, @new_options)
end