aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorPrathamesh Sonpatki <csonpatki@gmail.com>2016-11-24 15:12:45 +0530
committerPrathamesh Sonpatki <csonpatki@gmail.com>2016-11-24 17:33:16 +0530
commit312b345b45cc6cbbd832c789ac14f261da66c80f (patch)
treef968a6724a19a704e920739e781f2d00c08acd3a /activerecord
parent8556ab505a0a91efb529039b653984ab2b466a7e (diff)
downloadrails-312b345b45cc6cbbd832c789ac14f261da66c80f.tar.gz
rails-312b345b45cc6cbbd832c789ac14f261da66c80f.tar.bz2
rails-312b345b45cc6cbbd832c789ac14f261da66c80f.zip
Followup of UUID default extension in the docs [ci skip]
- Mentioned clearly that for PostgreSQL < 9.4, you need to pass the default option with "uuid_generate_v4()" - Also updated PostgreSQL Active Record guide with this change. - https://github.com/rails/rails/pull/25395#r66877078
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb
index 5d689c2dc3..ae1ec3e2b7 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb
@@ -12,11 +12,21 @@ module ActiveRecord
# end
#
# By default, this will use the +gen_random_uuid()+ function from the
- # +pgcrypto+ extension (only PostgreSQL >= 9.4), or +uuid_generate_v4()+
- # function from the +uuid-ossp+ extension. To enable the appropriate
- # extension, which is a requirement, you can use the +enable_extension+
- # method in your migrations. To use a UUID primary key without any of
- # of extensions, you can set the +:default+ option to +nil+:
+ # +pgcrypto+ extension. As that extension is only available in
+ # PostgreSQL 9.4+, for earlier versions an explicit default can be set
+ # to use +uuid_generate_v4()+ from the +uuid-ossp+ extension instead:
+ #
+ # create_table :stuffs, id: false do |t|
+ # t.primary_key :id, :uuid, default: "uuid_generate_v4()"
+ # t.uuid :foo_id
+ # t.timestamps
+ # end
+ #
+ # To enable the appropriate extension, which is a requirement, use
+ # the +enable_extension+ method in your migrations.
+ #
+ # To use a UUID primary key without any of the extensions, set the
+ # +:default+ option to +nil+:
#
# create_table :stuffs, id: false do |t|
# t.primary_key :id, :uuid, default: nil