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.



507
508
509
510
511
512
513
514
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 507

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.



503
504
505
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 503

def adds
  @adds
end

#check_constraint_addsObject (readonly)

Returns the value of attribute check_constraint_adds.



505
506
507
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 505

def check_constraint_adds
  @check_constraint_adds
end

#check_constraint_dropsObject (readonly)

Returns the value of attribute check_constraint_drops.



505
506
507
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 505

def check_constraint_drops
  @check_constraint_drops
end

#foreign_key_addsObject (readonly)

Returns the value of attribute foreign_key_adds.



504
505
506
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 504

def foreign_key_adds
  @foreign_key_adds
end

#foreign_key_dropsObject (readonly)

Returns the value of attribute foreign_key_drops.



504
505
506
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 504

def foreign_key_drops
  @foreign_key_drops
end

Instance Method Details

#add_check_constraint(expression, options) ⇒ Object



526
527
528
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 526

def add_check_constraint(expression, options)
  @check_constraint_adds << CheckConstraintDefinition.new(name, expression, options)
end

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



534
535
536
537
538
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 534

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



518
519
520
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 518

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

#drop_check_constraint(constraint_name) ⇒ Object



530
531
532
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 530

def drop_check_constraint(constraint_name)
  @check_constraint_drops << constraint_name
end

#drop_foreign_key(name) ⇒ Object



522
523
524
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 522

def drop_foreign_key(name)
  @foreign_key_drops << name
end

#nameObject



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

def name; @td.name; end