Class: ActiveRecord::ConnectionAdapters::AlterTable

Inherits:
Object
  • Object
show all
Defined in:
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb

Overview

:nodoc:

Direct Known Subclasses

PostgreSQL::AlterTable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(td) ⇒ AlterTable

Returns a new instance of AlterTable.



463
464
465
466
467
468
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 463

def initialize(td)
  @td   = td
  @adds = []
  @foreign_key_adds = []
  @foreign_key_drops = []
end

Instance Attribute Details

#addsObject (readonly)

Returns the value of attribute adds



459
460
461
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 459

def adds
  @adds
end

#foreign_key_addsObject (readonly)

Returns the value of attribute foreign_key_adds



460
461
462
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 460

def foreign_key_adds
  @foreign_key_adds
end

#foreign_key_dropsObject (readonly)

Returns the value of attribute foreign_key_drops



461
462
463
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 461

def foreign_key_drops
  @foreign_key_drops
end

Instance Method Details

#add_column(name, type, **options) ⇒ Object



480
481
482
483
484
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 480

def add_column(name, type, **options)
  name = name.to_s
  type = type.to_sym
  @adds << AddColumnDefinition.new(@td.new_column_definition(name, type, **options))
end

#add_foreign_key(to_table, options) ⇒ Object



472
473
474
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 472

def add_foreign_key(to_table, options)
  @foreign_key_adds << ForeignKeyDefinition.new(name, to_table, options)
end

#drop_foreign_key(name) ⇒ Object



476
477
478
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 476

def drop_foreign_key(name)
  @foreign_key_drops << name
end

#nameObject



470
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 470

def name; @td.name; end