diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-02-01 22:04:40 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-02-01 22:04:40 +0000 |
commit | a76010c99459559a29901ed75b847384248c7c6e (patch) | |
tree | f199e3f4187091a7a7c78f7fd6901529658174f7 /lib | |
parent | 9f9befeba613deff85c2325f629e77099d44af6f (diff) | |
parent | 18c9436ba00574d44dc258a2f231d4758b378eae (diff) |
Merge branch 'wdtk' into release/0.5
Conflicts:
locale/app.pot
Diffstat (limited to 'lib')
-rw-r--r-- | lib/patches/fixtures_constraint_disabling.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/patches/fixtures_constraint_disabling.rb b/lib/patches/fixtures_constraint_disabling.rb new file mode 100644 index 000000000..7d97e81f7 --- /dev/null +++ b/lib/patches/fixtures_constraint_disabling.rb @@ -0,0 +1,21 @@ +# An alternative way of disabling foreign keys in fixture loading in Postgres and +# does not require superuser permissions +# http://kopongo.com/2008/7/25/postgres-ri_constrainttrigger-error +require 'active_record/connection_adapters/postgresql_adapter' +module ActiveRecord + module ConnectionAdapters + class PostgreSQLAdapter < AbstractAdapter + def disable_referential_integrity(&block) + transaction { + begin + execute "SET CONSTRAINTS ALL DEFERRED" + yield + ensure + execute "SET CONSTRAINTS ALL IMMEDIATE" + end + } + end + end + end +end + |