module ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnMethods

Public Instance Methods

bigserial(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 38
def bigserial(*args, **options)
  args.each { |name| column(name, :bigserial, options) }
end
bit(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 42
def bit(*args, **options)
  args.each { |name| column(name, :bit, options) }
end
bit_varying(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 46
def bit_varying(*args, **options)
  args.each { |name| column(name, :bit_varying, options) }
end
box(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 114
def box(*args, **options)
  args.each { |name| column(name, :box, options) }
end
cidr(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 50
def cidr(*args, **options)
  args.each { |name| column(name, :cidr, options) }
end
circle(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 126
def circle(*args, **options)
  args.each { |name| column(name, :circle, options) }
end
citext(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 54
def citext(*args, **options)
  args.each { |name| column(name, :citext, options) }
end
daterange(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 58
def daterange(*args, **options)
  args.each { |name| column(name, :daterange, options) }
end
hstore(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 62
def hstore(*args, **options)
  args.each { |name| column(name, :hstore, options) }
end
inet(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 66
def inet(*args, **options)
  args.each { |name| column(name, :inet, options) }
end
int4range(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 70
def int4range(*args, **options)
  args.each { |name| column(name, :int4range, options) }
end
int8range(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 74
def int8range(*args, **options)
  args.each { |name| column(name, :int8range, options) }
end
json(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 78
def json(*args, **options)
  args.each { |name| column(name, :json, options) }
end
jsonb(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 82
def jsonb(*args, **options)
  args.each { |name| column(name, :jsonb, options) }
end
line(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 106
def line(*args, **options)
  args.each { |name| column(name, :line, options) }
end
lseg(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 110
def lseg(*args, **options)
  args.each { |name| column(name, :lseg, options) }
end
ltree(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 86
def ltree(*args, **options)
  args.each { |name| column(name, :ltree, options) }
end
macaddr(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 90
def macaddr(*args, **options)
  args.each { |name| column(name, :macaddr, options) }
end
money(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 94
def money(*args, **options)
  args.each { |name| column(name, :money, options) }
end
numrange(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 98
def numrange(*args, **options)
  args.each { |name| column(name, :numrange, options) }
end
path(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 118
def path(*args, **options)
  args.each { |name| column(name, :path, options) }
end
point(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 102
def point(*args, **options)
  args.each { |name| column(name, :point, options) }
end
polygon(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 122
def polygon(*args, **options)
  args.each { |name| column(name, :polygon, options) }
end
primary_key(name, type = :primary_key, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 33
def primary_key(name, type = :primary_key, **options)
  options[:default] = options.fetch(:default, 'uuid_generate_v4()') if type == :uuid
  super
end

Defines the primary key field. Use of the native 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 +uuid_generate_v4()+ function from the uuid-ossp extension, which MUST be enabled on your database. To enable the uuid-ossp extension, you can use the enable_extension method in your migrations. To use a UUID primary key without uuid-ossp enabled, you can 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 different UUID generation function from uuid-ossp or 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.

Calls superclass method
serial(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 130
def serial(*args, **options)
  args.each { |name| column(name, :serial, options) }
end
tsrange(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 134
def tsrange(*args, **options)
  args.each { |name| column(name, :tsrange, options) }
end
tstzrange(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 138
def tstzrange(*args, **options)
  args.each { |name| column(name, :tstzrange, options) }
end
tsvector(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 142
def tsvector(*args, **options)
  args.each { |name| column(name, :tsvector, options) }
end
uuid(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 146
def uuid(*args, **options)
  args.each { |name| column(name, :uuid, options) }
end
xml(*args, **options) Show source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 150
def xml(*args, **options)
  args.each { |name| column(name, :xml, options) }
end

© 2004–2018 David Heinemeier Hansson
Licensed under the MIT License.