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:
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

DSL Calls

included

[ GitHub ]


184
185
186
187
188
189
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 184

included do
  define_column_methods :bigserial, :bit, :bit_varying, :cidr, :citext, :daterange,
    :hstore, :inet, :interval, :int4range, :int8range, :jsonb, :ltree, :macaddr,
    :money, :numrange, :oid, :point, :line, :lseg, :box, :path, :polygon, :circle,
    :serial, :tsrange, :tstzrange, :tsvector, :uuid, :xml, :timestamptz, :enum
end

Instance Method Details

#bigserial(*names, **options)

[ GitHub ]

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

rdoc_method :method: bigserial

#bit(*names, **options)

[ GitHub ]

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

rdoc_method :method: bit

#bit_varying(*names, **options)

[ GitHub ]

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

rdoc_method :method: bit_varying

#box(*names, **options)

[ GitHub ]

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

rdoc_method :method: box

#cidr(*names, **options)

[ GitHub ]

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

rdoc_method :method: cidr

#circle(*names, **options)

[ GitHub ]

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

rdoc_method :method: circle

#citext(*names, **options)

[ GitHub ]

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

rdoc_method :method: citext

#daterange(*names, **options)

[ GitHub ]

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

rdoc_method :method: daterange

#enum(*names, **options)

[ GitHub ]

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

RDoc directive :method: enum

#hstore(*names, **options)

[ GitHub ]

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

rdoc_method :method: hstore

#inet(*names, **options)

[ GitHub ]

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

rdoc_method :method: inet

#int4range(*names, **options)

[ GitHub ]

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

rdoc_method :method: int4range

#int8range(*names, **options)

[ GitHub ]

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

rdoc_method :method: int8range

#interval(*names, **options)

[ GitHub ]

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

rdoc_method :method: interval

#jsonb(*names, **options)

[ GitHub ]

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

rdoc_method :method: jsonb

#line(*names, **options)

[ GitHub ]

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

rdoc_method :method: line

#lseg(*names, **options)

[ GitHub ]

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

rdoc_method :method: lseg

#ltree(*names, **options)

[ GitHub ]

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

rdoc_method :method: ltree

#macaddr(*names, **options)

[ GitHub ]

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

rdoc_method :method: macaddr

#money(*names, **options)

[ GitHub ]

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

rdoc_method :method: money

#numrange(*names, **options)

[ GitHub ]

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

rdoc_method :method: numrange

#oid(*names, **options)

[ GitHub ]

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

rdoc_method :method: oid

#path(*names, **options)

[ GitHub ]

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

rdoc_method :method: path

#point(*names, **options)

[ GitHub ]

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

rdoc_method :method: point

#polygon(*names, **options)

[ GitHub ]

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

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 48

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 153

rdoc_method :method: serial

#timestamptz(*names, **options)

[ GitHub ]

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

rdoc_method :method: timestamptz

#tsrange(*names, **options)

[ GitHub ]

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

rdoc_method :method: tsrange

#tstzrange(*names, **options)

[ GitHub ]

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

rdoc_method :method: tstzrange

#tsvector(*names, **options)

[ GitHub ]

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

rdoc_method :method: tsvector

#uuid(*names, **options)

[ GitHub ]

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

rdoc_method :method: uuid

#xml(*names, **options)

[ GitHub ]

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

rdoc_method :method: xml