aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Rhoades <createdbypete@gmail.com>2015-04-23 13:39:07 +1000
committerPeter Rhoades <createdbypete@gmail.com>2015-05-04 15:19:31 +1000
commit54becc956132e08ed8ed74819d85fe1e0b64fa94 (patch)
tree8eef0e23ae2310063cd304be81dff6275f4ff08a
parent40ff5087ec3c932d2b8f79425d8b741f7ed3f362 (diff)
downloadrails-54becc956132e08ed8ed74819d85fe1e0b64fa94.tar.gz
rails-54becc956132e08ed8ed74819d85fe1e0b64fa94.tar.bz2
rails-54becc956132e08ed8ed74819d85fe1e0b64fa94.zip
Provide mention of pgcrypto extension for uuids
From the Postgresql 9.4+ docs > If you only need randomly-generated (version 4) UUIDs, consider using the gen_random_uuid() function from the pgcrypto module instead. [ci skip]
-rw-r--r--guides/source/active_record_postgresql.md15
1 files changed, 9 insertions, 6 deletions
diff --git a/guides/source/active_record_postgresql.md b/guides/source/active_record_postgresql.md
index 66a11e5785..d11b091ada 100644
--- a/guides/source/active_record_postgresql.md
+++ b/guides/source/active_record_postgresql.md
@@ -242,10 +242,12 @@ article.save!
### UUID
-* [type definition](http://www.postgresql.org/docs/9.3/static/datatype-uuid.html)
-* [generator functions](http://www.postgresql.org/docs/9.3/static/uuid-ossp.html)
+* [type definition](http://www.postgresql.org/docs/9.4/static/datatype-uuid.html)
+* [pgcrypto generator function](http://www.postgresql.org/docs/9.4/static/pgcrypto.html#AEN159361)
+* [uuid-ossp generator functions](http://www.postgresql.org/docs/9.4/static/uuid-ossp.html)
-NOTE: you need to enable the `uuid-ossp` extension to use uuid.
+NOTE: you need to enable the `pgcrypto` (PostgreSQL >= 9.4) or `uuid-ossp`
+extension to use uuid.
```ruby
# db/migrate/20131220144913_create_revisions.rb
@@ -356,12 +358,13 @@ A point is casted to an array containing `x` and `y` coordinates.
UUID Primary Keys
-----------------
-NOTE: you need to enable the `uuid-ossp` extension to generate UUIDs.
+NOTE: you need to enable the `pgcrypto` (PostgreSQL >= 9.4) or `uuid-ossp`
+extension to generate random UUIDs.
```ruby
# db/migrate/20131220144913_create_devices.rb
-enable_extension 'uuid-ossp' unless extension_enabled?('uuid-ossp')
-create_table :devices, id: :uuid, default: 'uuid_generate_v4()' do |t|
+enable_extension 'pgcrypto' unless extension_enabled?('pgcrypto')
+create_table :devices, id: :uuid, default: 'gen_random_uuid()' do |t|
t.string :kind
end