Skip to content

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

Open

Description

@contentfree

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?)

Activity

  1. baschtl commented on Feb 24, 2017

    @baschtl

    @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;')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions