Class: DeclareSchema::SchemaChange::ColumnAdd
- Inherits:
-
Base
- Object
- Base
- DeclareSchema::SchemaChange::ColumnAdd
show all
- Defined in:
- lib/declare_schema/schema_change/column_add.rb
Instance Method Summary
collapse
Methods inherited from Base
#down, format_options, #up
Constructor Details
#initialize(table_name, column_name, column_type, **column_options) ⇒ ColumnAdd
Returns a new instance of ColumnAdd.
8
9
10
11
12
13
|
# File 'lib/declare_schema/schema_change/column_add.rb', line 8
def initialize(table_name, column_name, column_type, **column_options)
@table_name = table_name or raise ArgumentError, "must provide table_name"
@column_name = column_name or raise ArgumentError, "must provide column_name"
@column_type = column_type or raise ArgumentError, "must provide column_type"
@column_options = column_options
end
|
Instance Method Details
#down_command ⇒ Object
22
23
24
|
# File 'lib/declare_schema/schema_change/column_add.rb', line 22
def down_command
"remove_column #{@table_name.to_sym.inspect}, #{@column_name.to_sym.inspect}"
end
|
#up_command ⇒ Object
15
16
17
18
19
20
|
# File 'lib/declare_schema/schema_change/column_add.rb', line 15
def up_command
"add_column #{[@table_name.to_sym.inspect,
@column_name.to_sym.inspect,
@column_type.to_sym.inspect,
*self.class.format_options(@column_options)].join(", ")}"
end
|