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

Add support foreign key constraints #132

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

strangerxx
Copy link

Sorting table in list

@jeremy-ebler-vineti
Copy link

This worked for me.

Changes to the gemspec should be left to the maintainer.

I liked the reflect_on_all_associations(:belongs_to) approach. I was considering querying against information_schema to find foreign key restraints, but I think the reflection approach will be more portable. 👍

The code itself isn't very pragmatic Ruby. For example, the Dump module shouldn't have a public class_exists? method, there is a lot of repetition that can be refactored to be more readable, and Array.new instead of simply [] stands out.

@lenlo
Copy link

lenlo commented Jul 30, 2023

This is all good, but a simpler solution might be to just turn off foreign key constraint checking while loading the data. This is the approach that both MySQL and SQLite3 takes for their own SQL dumps and can easily be achived by wrapping the body of load_documents in:

ActiveRecord::Base.connection.disable_referential_integrity do
  ...
end

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

Successfully merging this pull request may close these issues.

3 participants