diff options
author | Fumiaki MATSUSHIMA <mtsmfm@gmail.com> | 2015-12-13 12:46:59 +0900 |
---|---|---|
committer | Fumiaki MATSUSHIMA <mtsmfm@gmail.com> | 2016-12-03 15:53:22 +0900 |
commit | e75fcdf3feaca7fac44dde23ea3059399c0ff384 (patch) | |
tree | d14355b4890d550393d07904155158fa88ac6648 /activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | |
parent | 26ea54aa7d1b0be66d5b99cab6e2f64c80fe4757 (diff) | |
download | rails-e75fcdf3feaca7fac44dde23ea3059399c0ff384.tar.gz rails-e75fcdf3feaca7fac44dde23ea3059399c0ff384.tar.bz2 rails-e75fcdf3feaca7fac44dde23ea3059399c0ff384.zip |
Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser privileges
ref: 72c1557254
- We must use `authors` fixture with `author_addresses` because of its foreign key constraint.
- Tests require PostgreSQL >= 9.4.2 because it had a bug about `ALTER CONSTRAINTS` and fixed in 9.4.2.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 6 |
1 files changed, 6 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 28e80a084a..734f7ed765 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -319,6 +319,12 @@ module ActiveRecord postgresql_version >= 90400 end + # PostgreSQL 9.4 introduces ALTER TABLE ... ALTER CONSTRAINT but it has a bug and fixed in 9.4.2 + # https://www.postgresql.org/docs/9.4/static/release-9-4-2.html + def supports_alter_constraint? + postgresql_version >= 90402 + 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") |