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

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

Instance Method Details

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

3.2 super expects (name)



1336
1337
1338
1339
1340
1341
1342
1343
1344
# File 'lib/arjdbc/postgresql/adapter.rb', line 1336

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



1329
1330
1331
1332
1333
1334
# File 'lib/arjdbc/postgresql/adapter.rb', line 1329

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