Class: DeclareSchema::SchemaChange::ColumnChange

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

Instance Method Summary collapse

Methods inherited from Base

#down, format_options, #up

Constructor Details

#initialize(table_name, column_name, old_type:, old_options:, new_type:, new_options:) ⇒ ColumnChange

Returns a new instance of ColumnChange.



8
9
10
11
12
13
14
15
# File 'lib/declare_schema/schema_change/column_change.rb', line 8

def initialize(table_name, column_name, old_type:, old_options:, new_type:, new_options:)
  @table_name = table_name
  @column_name = column_name
  @old_type = old_type
  @old_options = old_options
  @new_type = new_type
  @new_options = new_options
end

Instance Method Details

#down_commandObject



24
25
26
27
28
29
# File 'lib/declare_schema/schema_change/column_change.rb', line 24

def down_command
  "change_column #{[@table_name.to_sym.inspect,
                    @column_name.to_sym.inspect,
                    @old_type.to_sym.inspect,
                    *self.class.format_options(@old_options)].join(", ")}"
end

#up_commandObject



17
18
19
20
21
22
# File 'lib/declare_schema/schema_change/column_change.rb', line 17

def up_command
  "change_column #{[@table_name.to_sym.inspect,
                    @column_name.to_sym.inspect,
                    @new_type.to_sym.inspect,
                    *self.class.format_options(@new_options)].join(", ")}"
end