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.


553
554
555
556
557
558
559
560
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 553

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

Instance Attribute Details

#addsObject (readonly)

Returns the value of attribute adds.


549
550
551
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 549

def adds
  @adds
end

#check_constraint_addsObject (readonly)

Returns the value of attribute check_constraint_adds.


551
552
553
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 551

def check_constraint_adds
  @check_constraint_adds
end

#check_constraint_dropsObject (readonly)

Returns the value of attribute check_constraint_drops.


551
552
553
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 551

def check_constraint_drops
  @check_constraint_drops
end

#foreign_key_addsObject (readonly)

Returns the value of attribute foreign_key_adds.


550
551
552
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 550

def foreign_key_adds
  @foreign_key_adds
end

#foreign_key_dropsObject (readonly)

Returns the value of attribute foreign_key_drops.


550
551
552
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 550

def foreign_key_drops
  @foreign_key_drops
end

Instance Method Details

#add_check_constraint(expression, options) ⇒ Object


572
573
574
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 572

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

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


580
581
582
583
584
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 580

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


564
565
566
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 564

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


576
577
578
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 576

def drop_check_constraint(constraint_name)
  @check_constraint_drops << constraint_name
end

#drop_foreign_key(name) ⇒ Object


568
569
570
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 568

def drop_foreign_key(name)
  @foreign_key_drops << name
end

#nameObject


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

def name; @td.name; end