Skip to content

Commit

Permalink
JRUBY-3186: disable referential integrity for PG (Ryan Bell)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksieger committed Nov 26, 2008
1 parent 91babd5 commit 87f33e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions History.txt
Expand Up @@ -13,6 +13,7 @@
from court3nay)
- JRUBY-2715: Add create/drop database methods to Postgres (Peter Williams)
- JRUBY-3183: Fix structure dump for Postgres (Ryan Bell)
- JRUBY-3186: disable referential integrity for PG (Ryan Bell)
- Authoritative repository now hosted at
git://github.com/nicksieger/activerecord-jdbc-adapter.git; rubyforge
svn trunk cleaned out.
Expand Down
7 changes: 7 additions & 0 deletions lib/jdbc_adapter/jdbc_postgre.rb
Expand Up @@ -336,6 +336,13 @@ def quoted_date(value)
value.strftime("%Y-%m-%d %H:%M:%S")
end

def disable_referential_integrity(&block) #:nodoc:
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER ALL" }.join(";"))
yield
ensure
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER ALL" }.join(";"))
end

def rename_table(name, new_name)
execute "ALTER TABLE #{name} RENAME TO #{new_name}"
end
Expand Down

0 comments on commit 87f33e5

Please sign in to comment.