Created
November 4, 2011 12:14
-
-
Save psy-q/1339208 to your computer and use it in GitHub Desktop.
20110117113700_remove_fk_indices.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RemoveFkIndices < ActiveRecord::Migration | |
| # Remove old foreign key remains | |
| def self.up | |
| # MySQL and ActiveRecord produce problems with each other: | |
| # http://lists.mysql.com/mysql/204151 | |
| # http://lists.mysql.com/mysql/204199 | |
| # http://bugs.mysql.com/bug.php?id=10333 | |
| # AR seems to guess the wrong foreign key name, which it can't remove. | |
| execute "ALTER TABLE contract_lines DROP FOREIGN KEY fk_contract_lines_contract_id" | |
| execute "ALTER TABLE contract_lines DROP KEY fk_contract_lines_contract_id" | |
| execute "ALTER TABLE contract_lines DROP FOREIGN KEY fk_contract_lines_item_id" | |
| execute "ALTER TABLE contract_lines DROP KEY fk_contract_lines_item_id" | |
| execute "ALTER TABLE contract_lines DROP FOREIGN KEY fk_contract_lines_model_id" | |
| execute "ALTER TABLE contract_lines DROP KEY fk_contract_lines_model_id" | |
| execute "ALTER TABLE contract_lines DROP FOREIGN KEY fk_contract_lines_option_id" | |
| # use default name for indices | |
| change_table :contract_lines do |t| | |
| t.index :contract_id | |
| t.index :item_id | |
| t.index :model_id | |
| end | |
| end | |
| def self.down | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment