Permalink
Browse files

Merge pull request #8548 from garysweaver/postgresql_fallback_to_disa…

…ble_user_triggers

fix #5523: postgresql adapter to disable user triggers in disable_referential_integrity
  • Loading branch information...
2 parents 15c40b2 + 9bb27f7 commit e4003adff93a1379a5e632f7e199c61bf34c293d @rafaelfranca rafaelfranca committed Dec 18, 2012
@@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
+* Add ability for postgresql adapter to disable user triggers in disable_referential_integrity.
+ Fix #5523
+
+ *Gary S. Weaver*
+
* Added support for `validates_uniqueness_of` in PostgreSQL array columns.
Fixes #8075.
@@ -7,13 +7,21 @@ def supports_disable_referential_integrity? #:nodoc:
end
def disable_referential_integrity #:nodoc:
- if supports_disable_referential_integrity? then
- execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER ALL" }.join(";"))
+ if supports_disable_referential_integrity?
+ begin
+ execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER ALL" }.join(";"))
+ rescue
+ execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER USER" }.join(";"))
+ end
end
yield
ensure
- if supports_disable_referential_integrity? then
- execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER ALL" }.join(";"))
+ if supports_disable_referential_integrity?
+ begin
+ execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER ALL" }.join(";"))
+ rescue
+ execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER USER" }.join(";"))
+ end
end
end
end

0 comments on commit e4003ad

Please sign in to comment.