Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referential Integrity causes foreign key errors with creation of fixtures #43

Closed
DaveWhitmer opened this issue Aug 6, 2018 · 4 comments

Comments

@DaveWhitmer
Copy link

Adding the gem caused my test suite to fail due to foreign key index violations with fixture creations.
Simple fix is just to change referential_integrity.rb to:

# Workaround for https://github.com/citusdata/citus/issues/1080
# "Support DISABLE/ENABLE TRIGGER ALL on distributed tables"

require 'active_record/connection_adapters/postgresql_adapter'

module ActiveRecord
  module ConnectionAdapters
    class PostgreSQLAdapter < AbstractAdapter
      def supports_disable_referential_integrity?
        if Rails.env.test?
          true
        else
          false
        end
      end
    end
  end
end

Not sure if there are any unintended consequences...

@lfittl
Copy link
Contributor

lfittl commented Aug 6, 2018

@DaveWhitmer Hmm - that issue should be fixed though, so this shouldn't be necessary anymore.

Which Citus version are you testing against?

@DaveWhitmer
Copy link
Author

Should be 7.5, but have not even gotten to that stage. Simply installed the gem in preparation for the move to Citus and my test suite started failing as described above. Remove the gem and the test suite passes. Dug into it and found that it was the fixture creation with the referential integrity as described above. Forked the gem added that monkey patch to it and everything passed.

@lfittl
Copy link
Contributor

lfittl commented Aug 6, 2018

Ah, this is caused by https://github.com/citusdata/activerecord-multi-tenant/blob/master/lib/activerecord-multi-tenant/referential_integrity.rb which wasn't removed yet even though this was fixed in Citus.

Given that this has been supported since Citus 6.2 I'd be inclined to simply remove that monkey patch.

Since you already forked the gem, could you try just removing that monkey patch from it, and see if that also makes things pass? (to confirm the patch is the issue)

@DaveWhitmer
Copy link
Author

Yes. Commenting out the entirety of the referential_integrity.rb file causes my local test environment to pass as I would expect.

piotaixr added a commit to ekylibre/activerecord-multi-tenant that referenced this issue Mar 6, 2019
@lfittl lfittl closed this as completed in 3bb1f0f Mar 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants