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

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

Comments

Projects
None yet
3 participants

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

Owner

rafaelfranca commented Feb 15, 2012

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

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

@jeremy jeremy closed this in f174e84 Feb 15, 2012

Can this also go into 3-2-stable?

Owner

rafaelfranca commented Feb 26, 2012

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

@rafaelfranca rafaelfranca added a commit to rafaelfranca/omg-rails that referenced this issue Feb 27, 2012

@rafaelfranca @tenderlove rafaelfranca + tenderlove Revert "No need to pass options which is never used"
Options is needed for some Rails extensions to determine when
referential integrity should be disabled

This reverts commit bcb466c.

Fixes #5052
663904f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment