Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::TableDefinition

Inherits:
TableDefinition
  • Object
show all
Includes:
ColumnMethods
Defined in:
lib/arjdbc/postgresql/adapter.rb

Instance Method Summary collapse

Methods included from ColumnMethods

#bit, #bit_varying, #cidr, #daterange, #hstore, #inet, #int4range, #int8range, #json, #jsonb, #ltree, #macaddr, #numrange, #tsrange, #tstzrange, #tsvector, #uuid, #xml

Instance Method Details

#column(name, type = nil, options = {}) ⇒ Object

3.2 super expects (name)



1505
1506
1507
1508
1509
1510
1511
1512
1513
# File 'lib/arjdbc/postgresql/adapter.rb', line 1505

def column(name, type = nil, options = {})
  super
  column = self[name]
  # NOTE: <= 3.1 no #new_column_definition hard-coded ColumnDef.new :
  # column = self[name] || ColumnDefinition.new(@base, name, type)
  # thus we simply do not support array column definitions on <= 3.1
  column.array = options[:array] if column.is_a?(ColumnDefinition)
  self
end

#primary_key(name, type = :primary_key, options = {}) ⇒ Object



1498
1499
1500
1501
1502
1503
# File 'lib/arjdbc/postgresql/adapter.rb', line 1498

def primary_key(name, type = :primary_key, options = {})
  return super unless type == :uuid
  options[:default] = options.fetch(:default, 'uuid_generate_v4()')
  options[:primary_key] = true
  column name, type, options
end