Skip to content

Commit 14a75a5

Browse files
Improve docs for postgresql with uuid primary keys [ci skip]
Introduced in 09ac177.
1 parent 8a7c2e1 commit 14a75a5

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,10 @@ class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
340340
# end
341341
#
342342
# By default, this will use the +uuid_generate_v4()+ function from the
343-
# +uuid-ossp+ extension, which MUST be enabled on your databse. To enable
343+
# +uuid-ossp+ extension, which MUST be enabled on your database. To enable
344344
# the +uuid-ossp+ extension, you can use the +enable_extension+ method in your
345-
# migrations To use a UUID primary key without +uuid-ossp+ enabled, you can
346-
# set the +:default+ option to nil:
345+
# migrations. To use a UUID primary key without +uuid-ossp+ enabled, you can
346+
# set the +:default+ option to +nil+:
347347
#
348348
# create_table :stuffs, id: false do |t|
349349
# t.primary_key :id, :uuid, default: nil
@@ -354,11 +354,10 @@ class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
354354
# You may also pass a different UUID generation function from +uuid-ossp+
355355
# or another library.
356356
#
357-
# Note that setting the UUID primary key default value to +nil+
358-
# will require you to assure that you always provide a UUID value
359-
# before saving a record (as primary keys cannot be nil). This might be
360-
# done via the SecureRandom.uuid method and a +before_save+ callback,
361-
# for instance.
357+
# Note that setting the UUID primary key default value to +nil+ will
358+
# require you to assure that you always provide a UUID value before saving
359+
# a record (as primary keys cannot be +nil+). This might be done via the
360+
# +SecureRandom.uuid+ method and a +before_save+ callback, for instance.
362361
def primary_key(name, type = :primary_key, options = {})
363362
return super unless type == :uuid
364363
options[:default] = options.fetch(:default, 'uuid_generate_v4()')

activerecord/test/cases/adapters/postgresql/uuid_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class UUID < ActiveRecord::Base
5959

6060
def setup
6161
@connection = ActiveRecord::Base.connection
62-
6362
@connection.reconnect!
6463

6564
@connection.transaction do

0 commit comments

Comments
 (0)