123456789_123456789_123456789_123456789_123456789_

Module: ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnMethods

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ConnectionAdapters::ColumnMethods::ClassMethods, ::ActiveSupport::Concern
Defined in: activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb

Class Method Summary

::ActiveSupport::Concern - Extended

class_methods

Define class methods from given block.

included

Evaluate given block in context of base class, so that you can write class macros here.

prepended

Evaluate given block in context of base class, so that you can write class macros here.

append_features, prepend_features

Instance Method Summary

Instance Method Details

#bigserial(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 58

rdoc_method :method: bigserial

#bit(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 62

rdoc_method :method: bit

#bit_varying(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 66

rdoc_method :method: bit_varying

#box(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 138

rdoc_method :method: box

#cidr(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 70

rdoc_method :method: cidr

#circle(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 150

rdoc_method :method: circle

#citext(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 74

rdoc_method :method: citext

#daterange(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 78

rdoc_method :method: daterange

#enum(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 186

rdoc_method :method: enum

#hstore(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 82

rdoc_method :method: hstore

#inet(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 86

rdoc_method :method: inet

#int4range(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 94

rdoc_method :method: int4range

#int8range(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 98

rdoc_method :method: int8range

#interval(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 90

rdoc_method :method: interval

#jsonb(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 102

rdoc_method :method: jsonb

#line(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 130

rdoc_method :method: line

#lseg(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 134

rdoc_method :method: lseg

#ltree(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 106

rdoc_method :method: ltree

#macaddr(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 110

rdoc_method :method: macaddr

#money(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 114

rdoc_method :method: money

#numrange(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 118

rdoc_method :method: numrange

#oid(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 122

rdoc_method :method: oid

#path(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 142

rdoc_method :method: path

#point(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 126

rdoc_method :method: point

#polygon(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 146

rdoc_method :method: polygon

#primary_key(name, type = :primary_key, **options)

Defines the primary key field. Use of the native ::ActiveRecord::ConnectionAdapters::PostgreSQL UUID type is supported, and can be used by defining your tables as such:

create_table :stuffs, id: :uuid do |t|
  t.string :content
  t.timestamps
end

By default, this will use the gen_random_uuid() function from the pgcrypto extension. As that extension is only available in ::ActiveRecord::ConnectionAdapters::PostgreSQL 9.4+, for earlier versions an explicit default can be set to use uuid_generate_v4() from the uuid-ossp extension instead:

create_table :stuffs, id: false do |t|
  t.primary_key :id, :uuid, default: "uuid_generate_v4()"
  t.uuid :foo_id
  t.timestamps
end

To enable the appropriate extension, which is a requirement, use the enable_extension method in your migrations.

To use a UUID primary key without any of the extensions, set the :default option to nil:

create_table :stuffs, id: false do |t|
  t.primary_key :id, :uuid, default: nil
  t.uuid :foo_id
  t.timestamps
end

You may also pass a custom stored procedure that returns a UUID or use a different UUID generation function from another library.

Note that setting the UUID primary key default value to nil will require you to assure that you always provide a UUID value before saving a record (as primary keys cannot be nil). This might be done via the SecureRandom.uuid method and a before_save callback, for instance.

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 49

def primary_key(name, type = :primary_key, **options)
  if type == :uuid
    options[:default] = options.fetch(:default, "gen_random_uuid()")
  end

  super
end

#serial(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 154

rdoc_method :method: serial

#timestamptz(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 178

rdoc_method :method: timestamptz

#tsrange(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 158

rdoc_method :method: tsrange

#tstzrange(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 162

rdoc_method :method: tstzrange

#tsvector(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 166

rdoc_method :method: tsvector

#uuid(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 170

rdoc_method :method: uuid

#xml(*names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 174

rdoc_method :method: xml