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

Truncation via Sequel fails on Mysql when foreign key constraints are present #7

Open
contentfree opened this issue Aug 14, 2014 · 1 comment

Comments

@contentfree
Copy link

ActiveRecord has disable_referential_integrity; unfortunately Sequel doesn't. Documentation for working around this would be very useful. (Maybe doing a raw SQL statement to disable foreign keys before doing the clean?)

@baschtl
Copy link

baschtl commented Feb 24, 2017

@contentfree A bit late, but I ran into the same issue. I am using MySQL and solved it like this:

DB.run('SET FOREIGN_KEY_CHECKS=0;')
DatabaseCleaner.clean_with(:truncation)
DB.run('SET FOREIGN_KEY_CHECKS=1;')

@botandrose botandrose transferred this issue from DatabaseCleaner/database_cleaner Feb 18, 2020
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