Class: ActiveRecord::ConnectionAdapters::AlterTable

Inherits:
Object
  • Object
show all
Defined in:
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.



630
631
632
633
634
635
636
637
638
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 630

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

Instance Attribute Details

#addsObject (readonly)

Returns the value of attribute adds.



625
626
627
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 625

def adds
  @adds
end

#check_constraint_addsObject (readonly)

Returns the value of attribute check_constraint_adds.



627
628
629
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 627

def check_constraint_adds
  @check_constraint_adds
end

#check_constraint_dropsObject (readonly)

Returns the value of attribute check_constraint_drops.



627
628
629
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 627

def check_constraint_drops
  @check_constraint_drops
end

#constraint_dropsObject (readonly)

Returns the value of attribute constraint_drops.



628
629
630
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 628

def constraint_drops
  @constraint_drops
end

#foreign_key_addsObject (readonly)

Returns the value of attribute foreign_key_adds.



626
627
628
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 626

def foreign_key_adds
  @foreign_key_adds
end

#foreign_key_dropsObject (readonly)

Returns the value of attribute foreign_key_drops.



626
627
628
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 626

def foreign_key_drops
  @foreign_key_drops
end

Instance Method Details

#add_check_constraint(expression, options) ⇒ Object



650
651
652
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 650

def add_check_constraint(expression, options)
  @check_constraint_adds << @td.new_check_constraint_definition(expression, options)
end

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



662
663
664
665
666
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 662

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



642
643
644
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 642

def add_foreign_key(to_table, options)
  @foreign_key_adds << @td.new_foreign_key_definition(to_table, options)
end

#drop_check_constraint(constraint_name) ⇒ Object



654
655
656
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 654

def drop_check_constraint(constraint_name)
  @check_constraint_drops << constraint_name
end

#drop_constraint(constraint_name) ⇒ Object



658
659
660
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 658

def drop_constraint(constraint_name)
  @constraint_drops << constraint_name
end

#drop_foreign_key(name) ⇒ Object



646
647
648
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 646

def drop_foreign_key(name)
  @foreign_key_drops << name
end

#nameObject



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

def name; @td.name; end