Skip to content

Commit 43e0aee

Browse files
authored
Merge pull request rails#27165 from prathamesh-sonpatki/followup-uuid-extension-change
Followup of UUID default extension in the docs
2 parents f243e7f + 312b345 commit 43e0aee

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,21 @@ module ColumnMethods
1212
# end
1313
#
1414
# By default, this will use the +gen_random_uuid()+ function from the
15-
# +pgcrypto+ extension (only PostgreSQL >= 9.4), or +uuid_generate_v4()+
16-
# function from the +uuid-ossp+ extension. To enable the appropriate
17-
# extension, which is a requirement, you can use the +enable_extension+
18-
# method in your migrations. To use a UUID primary key without any of
19-
# of extensions, you can set the +:default+ option to +nil+:
15+
# +pgcrypto+ extension. As that extension is only available in
16+
# PostgreSQL 9.4+, for earlier versions an explicit default can be set
17+
# to use +uuid_generate_v4()+ from the +uuid-ossp+ extension instead:
18+
#
19+
# create_table :stuffs, id: false do |t|
20+
# t.primary_key :id, :uuid, default: "uuid_generate_v4()"
21+
# t.uuid :foo_id
22+
# t.timestamps
23+
# end
24+
#
25+
# To enable the appropriate extension, which is a requirement, use
26+
# the +enable_extension+ method in your migrations.
27+
#
28+
# To use a UUID primary key without any of the extensions, set the
29+
# +:default+ option to +nil+:
2030
#
2131
# create_table :stuffs, id: false do |t|
2232
# t.primary_key :id, :uuid, default: nil

guides/source/active_record_postgresql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ device = Device.create
422422
device.id # => "814865cd-5a1d-4771-9306-4268f188fe9e"
423423
```
424424

425-
NOTE: `uuid_generate_v4()` (from `uuid-ossp`) is assumed if no `:default` option was
425+
NOTE: `gen_random_uuid()` (from `pgcrypto`) is assumed if no `:default` option was
426426
passed to `create_table`.
427427

428428
Full Text Search

0 commit comments

Comments
 (0)