diff options
author | Yaw Boakye <wheresyaw@gmail.com> | 2016-07-08 03:22:37 +0000 |
---|---|---|
committer | Yaw Boakye <wheresyaw@gmail.com> | 2016-11-22 22:11:18 +0000 |
commit | b915b11cca558eb99b7c2621c4457491d4bdb43b (patch) | |
tree | 647d9ff0be8cce2d56efa5e589e2e28a5bcd9808 /activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | |
parent | 49aa974ec8b15721d53b3b6abea88bd6ba433a68 (diff) | |
download | rails-b915b11cca558eb99b7c2621c4457491d4bdb43b.tar.gz rails-b915b11cca558eb99b7c2621c4457491d4bdb43b.tar.bz2 rails-b915b11cca558eb99b7c2621c4457491d4bdb43b.zip |
For `PostgreSQL >= 9.4` use `gen_random_uuid()`
Since 9.4, PostgreSQL recommends using `pgcrypto`'s `gen_random_uuid()`
to generate version 4 UUIDs instead of the functions in the `uuid-ossp`
extension.
These changes uses the appropriate UUID function depending on the
underlying PostgreSQL server's version, while maintaining
`uuid_generate_v4()` in older migrations.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 710b5cd887..140ad4827a 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -315,6 +315,10 @@ module ActiveRecord postgresql_version >= 90300 end + def supports_pgcrypto_uuid? + postgresql_version >= 90400 + end + def get_advisory_lock(lock_id) # :nodoc: unless lock_id.is_a?(Integer) && lock_id.bit_length <= 63 raise(ArgumentError, "Postgres requires advisory lock ids to be a signed 64 bit integer") |