class ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition

def create_column_definition(name, type)

def create_column_definition(name, type)
  PostgreSQL::ColumnDefinition.new name, type
end

def new_column_definition(name, type, options) # :nodoc:

:nodoc:
def new_column_definition(name, type, options) # :nodoc:
  column = super
  column.array = options[:array]
  column
end

def primary_key(name, type = :primary_key, options = {})

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

or another library.
You may also pass a different UUID generation function from +uuid-ossp+

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

set the +:default+ option to +nil+:
migrations. To use a UUID primary key without +uuid-ossp+ enabled, you can
the +uuid-ossp+ extension, you can use the +enable_extension+ method in your
+uuid-ossp+ extension, which MUST be enabled on your database. To enable
By default, this will use the +uuid_generate_v4()+ function from the

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

by defining your tables as such:
Use of the native PostgreSQL UUID type is supported, and can be used
Defines the primary key field.
def primary_key(name, type = :primary_key, options = {})
  return super unless type == :uuid
  options[:default] = options.fetch(:default, 'uuid_generate_v4()')
  options[:primary_key] = true
  column name, type, options
end