mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #19868 from createdbypete/guides-postgres-uuid-pgcrypto
Provide mention of pgcrypto extension for Postgres UUID support [ci skip]
This commit is contained in:
commit
a7e2ae3594
1 changed files with 9 additions and 6 deletions
|
@ -242,10 +242,12 @@ article.save!
|
||||||
|
|
||||||
### UUID
|
### UUID
|
||||||
|
|
||||||
* [type definition](http://www.postgresql.org/docs/9.3/static/datatype-uuid.html)
|
* [type definition](http://www.postgresql.org/docs/9.4/static/datatype-uuid.html)
|
||||||
* [generator functions](http://www.postgresql.org/docs/9.3/static/uuid-ossp.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
|
```ruby
|
||||||
# db/migrate/20131220144913_create_revisions.rb
|
# 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
|
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
|
```ruby
|
||||||
# db/migrate/20131220144913_create_devices.rb
|
# db/migrate/20131220144913_create_devices.rb
|
||||||
enable_extension 'uuid-ossp' unless extension_enabled?('uuid-ossp')
|
enable_extension 'pgcrypto' unless extension_enabled?('pgcrypto')
|
||||||
create_table :devices, id: :uuid, default: 'uuid_generate_v4()' do |t|
|
create_table :devices, id: :uuid, default: 'gen_random_uuid()' do |t|
|
||||||
t.string :kind
|
t.string :kind
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue