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

Re-add options to drop_table #5052

Closed
matthuhiggins opened this issue Feb 15, 2012 · 4 comments · Fixed by #5054
Closed

Re-add options to drop_table #5052

matthuhiggins opened this issue Feb 15, 2012 · 4 comments · Fixed by #5054

Comments

@matthuhiggins
Copy link

In Rails 3.0 and Rails 3.1, the method signature for drop_table was


In Rails 3.2, it changed to

The options hash is used by foreigner to determine whether disable_referential_integrity should be called:
https://github.com/matthuhiggins/foreigner/blob/master/lib/foreigner/connection_adapters/sql2003.rb#L8

On Rails 3.2, no options are passed, so :force is always false. This ultimately prevents "rake db:schema:load" from working on databases with foreign_keys, which means running "rake test" also breaks.

I created a sample app that causes this problem at https://github.com/matthuhiggins/broken_foreign_keys. Run the following to reproduce:


You will see this error:
```Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails: DROP TABLE shoes

@rafaelfranca
Copy link
Member

Done in my pull request. I'm only waiting someone to merge it. Thanks for reporting.

@matthuhiggins
Copy link
Author

Thanks. I'm also open to other solutions, because this requires that Rails knows about an external gem.

@jeremy jeremy closed this as completed in f174e84 Feb 15, 2012
@matthuhiggins
Copy link
Author

Can this also go into 3-2-stable?

@rafaelfranca
Copy link
Member

I think so. @tenderlove could you cherry-pick this commit?

rafaelfranca added a commit to rafaelfranca/omg-rails that referenced this issue Feb 27, 2012
Options is needed for some Rails extensions to determine when
referential integrity should be disabled

This reverts commit bcb466c.

Fixes rails#5052
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 a pull request may close this issue.

3 participants