Skip to content

Instantly share code, notes, and snippets.

@matthewrudy
Created November 22, 2010 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewrudy/709480 to your computer and use it in GitHub Desktop.
Save matthewrudy/709480 to your computer and use it in GitHub Desktop.
an initializer for Rails 3, to fix compatability with postgres 9.0.1 and fixture loading when using foreign keys
# HACK
# rails 3.0.3 doesn't turn off foreign keys on postgres 9.0.1
# consider removing this after rails 3.0.4
# https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5635-postgresql_adapter-doesnt-disable-referential-integrity-for-pg-90#ticket-5635-5
require 'active_record/connection_adapters/postgresql_adapter'
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter < AbstractAdapter
# REFERENTIAL INTEGRITY ====================================
# ### BREAKS FOR 9.0.1
# def supports_disable_referential_integrity?() #:nodoc:
# version = query("SHOW server_version")[0][0].split('.')
# version[0].to_i >= 8 && version[1].to_i >= 1
# rescue
# return false
# end
def supports_disable_referential_integrity?
postgresql_version >= 80100
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment