Class: ActiveRecord::ConnectionAdapters::AlterTable
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::AlterTable
- Defined in:
- lib/active_record/connection_adapters/abstract/schema_definitions.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary collapse
-
#adds ⇒ Object
readonly
Returns the value of attribute adds.
-
#foreign_key_adds ⇒ Object
readonly
Returns the value of attribute foreign_key_adds.
-
#foreign_key_drops ⇒ Object
readonly
Returns the value of attribute foreign_key_drops.
Instance Method Summary collapse
- #add_column(name, type, **options) ⇒ Object
- #add_foreign_key(to_table, options) ⇒ Object
- #drop_foreign_key(name) ⇒ Object
-
#initialize(td) ⇒ AlterTable
constructor
A new instance of AlterTable.
- #name ⇒ Object
Constructor Details
#initialize(td) ⇒ AlterTable
Returns a new instance of AlterTable.
467 468 469 470 471 472 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 467 def initialize(td) @td = td @adds = [] @foreign_key_adds = [] @foreign_key_drops = [] end |
Instance Attribute Details
#adds ⇒ Object (readonly)
Returns the value of attribute adds.
463 464 465 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 463 def adds @adds end |
#foreign_key_adds ⇒ Object (readonly)
Returns the value of attribute foreign_key_adds.
464 465 466 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 464 def foreign_key_adds @foreign_key_adds end |
#foreign_key_drops ⇒ Object (readonly)
Returns the value of attribute foreign_key_drops.
465 466 467 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 465 def foreign_key_drops @foreign_key_drops end |
Instance Method Details
#add_column(name, type, **options) ⇒ Object
484 485 486 487 488 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 484 def add_column(name, type, **) name = name.to_s type = type.to_sym @adds << AddColumnDefinition.new(@td.new_column_definition(name, type, **)) end |
#add_foreign_key(to_table, options) ⇒ Object
476 477 478 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 476 def add_foreign_key(to_table, ) @foreign_key_adds << ForeignKeyDefinition.new(name, to_table, ) end |
#drop_foreign_key(name) ⇒ Object
480 481 482 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 480 def drop_foreign_key(name) @foreign_key_drops << name end |
#name ⇒ Object
474 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 474 def name; @td.name; end |