1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Improve docs for postgresql with uuid primary keys [ci skip]

Introduced in 09ac1776ab.
This commit is contained in:
Carlos Antonio da Silva 2013-05-01 21:24:43 -03:00
parent 8a7c2e1cdf
commit 14a75a54a8
2 changed files with 7 additions and 9 deletions

View file

@ -340,10 +340,10 @@ module ActiveRecord
# end
#
# By default, this will use the +uuid_generate_v4()+ function from the
# +uuid-ossp+ extension, which MUST be enabled on your databse. To enable
# +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:
# 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
@ -354,11 +354,10 @@ module ActiveRecord
# 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.
# 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.
def primary_key(name, type = :primary_key, options = {})
return super unless type == :uuid
options[:default] = options.fetch(:default, 'uuid_generate_v4()')

View file

@ -59,7 +59,6 @@ class PostgresqlUUIDTestNilDefault < ActiveRecord::TestCase
def setup
@connection = ActiveRecord::Base.connection
@connection.reconnect!
@connection.transaction do