Methods

Instance Public methods

bigserial(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 54
        def bigserial(*args, **options)
          args.each { |name| column(name, :bigserial, options) }
        end
🔎 See on GitHub

bit(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 58
        def bit(*args, **options)
          args.each { |name| column(name, :bit, options) }
        end
🔎 See on GitHub

bit_varying(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 62
        def bit_varying(*args, **options)
          args.each { |name| column(name, :bit_varying, options) }
        end
🔎 See on GitHub

box(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 134
        def box(*args, **options)
          args.each { |name| column(name, :box, options) }
        end
🔎 See on GitHub

cidr(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 66
        def cidr(*args, **options)
          args.each { |name| column(name, :cidr, options) }
        end
🔎 See on GitHub

circle(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 146
        def circle(*args, **options)
          args.each { |name| column(name, :circle, options) }
        end
🔎 See on GitHub

citext(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 70
        def citext(*args, **options)
          args.each { |name| column(name, :citext, options) }
        end
🔎 See on GitHub

daterange(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 74
        def daterange(*args, **options)
          args.each { |name| column(name, :daterange, options) }
        end
🔎 See on GitHub

hstore(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 78
        def hstore(*args, **options)
          args.each { |name| column(name, :hstore, options) }
        end
🔎 See on GitHub

inet(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 82
        def inet(*args, **options)
          args.each { |name| column(name, :inet, options) }
        end
🔎 See on GitHub

int4range(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 90
        def int4range(*args, **options)
          args.each { |name| column(name, :int4range, options) }
        end
🔎 See on GitHub

int8range(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 94
        def int8range(*args, **options)
          args.each { |name| column(name, :int8range, options) }
        end
🔎 See on GitHub

interval(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 86
        def interval(*args, **options)
          args.each { |name| column(name, :interval, options) }
        end
🔎 See on GitHub

jsonb(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 98
        def jsonb(*args, **options)
          args.each { |name| column(name, :jsonb, options) }
        end
🔎 See on GitHub

line(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 126
        def line(*args, **options)
          args.each { |name| column(name, :line, options) }
        end
🔎 See on GitHub

lseg(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 130
        def lseg(*args, **options)
          args.each { |name| column(name, :lseg, options) }
        end
🔎 See on GitHub

ltree(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 102
        def ltree(*args, **options)
          args.each { |name| column(name, :ltree, options) }
        end
🔎 See on GitHub

macaddr(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 106
        def macaddr(*args, **options)
          args.each { |name| column(name, :macaddr, options) }
        end
🔎 See on GitHub

money(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 110
        def money(*args, **options)
          args.each { |name| column(name, :money, options) }
        end
🔎 See on GitHub

numrange(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 114
        def numrange(*args, **options)
          args.each { |name| column(name, :numrange, options) }
        end
🔎 See on GitHub

oid(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 118
        def oid(*args, **options)
          args.each { |name| column(name, :oid, options) }
        end
🔎 See on GitHub

path(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 138
        def path(*args, **options)
          args.each { |name| column(name, :path, options) }
        end
🔎 See on GitHub

point(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 122
        def point(*args, **options)
          args.each { |name| column(name, :point, options) }
        end
🔎 See on GitHub

polygon(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 142
        def polygon(*args, **options)
          args.each { |name| column(name, :polygon, options) }
        end
🔎 See on GitHub

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

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 +gen_random_uuid()+ function from the pgcrypto extension. As that extension is only available in 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.

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 46
        def primary_key(name, type = :primary_key, **options)
          if type == :uuid
            options[:default] = options.fetch(:default, "gen_random_uuid()")
          end

          super
        end
🔎 See on GitHub

serial(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 150
        def serial(*args, **options)
          args.each { |name| column(name, :serial, options) }
        end
🔎 See on GitHub

tsrange(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 154
        def tsrange(*args, **options)
          args.each { |name| column(name, :tsrange, options) }
        end
🔎 See on GitHub

tstzrange(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 158
        def tstzrange(*args, **options)
          args.each { |name| column(name, :tstzrange, options) }
        end
🔎 See on GitHub

tsvector(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 162
        def tsvector(*args, **options)
          args.each { |name| column(name, :tsvector, options) }
        end
🔎 See on GitHub

uuid(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 166
        def uuid(*args, **options)
          args.each { |name| column(name, :uuid, options) }
        end
🔎 See on GitHub

xml(*args, **options)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 170
        def xml(*args, **options)
          args.each { |name| column(name, :xml, options) }
        end
🔎 See on GitHub