aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_postgresql.md
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2015-05-05 09:18:23 +0200
committerYves Senn <yves.senn@gmail.com>2015-05-05 09:19:26 +0200
commita7e2ae35944e005d7fa89b8d7f44e7960492b6fa (patch)
treea8444e45c06e730e643e51c35227ad8cef31b637 /guides/source/active_record_postgresql.md
parentd687881fa80c7f4f09403d3ba64dd84bb1553d02 (diff)
parent54becc956132e08ed8ed74819d85fe1e0b64fa94 (diff)
downloadrails-a7e2ae35944e005d7fa89b8d7f44e7960492b6fa.tar.gz
rails-a7e2ae35944e005d7fa89b8d7f44e7960492b6fa.tar.bz2
rails-a7e2ae35944e005d7fa89b8d7f44e7960492b6fa.zip
Merge pull request #19868 from createdbypete/guides-postgres-uuid-pgcrypto
Provide mention of pgcrypto extension for Postgres UUID support [ci skip]
Diffstat (limited to 'guides/source/active_record_postgresql.md')
-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..5e58d5baeb 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` (only 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` (only 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