Skip to content

Commit

Permalink
remove fk constraints before dropping columns for mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy Kalinin and Mark Rushakoff committed Mar 26, 2013
1 parent 42a6a55 commit 11f03e9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions db/migrations/20130323005501_remove_framework_and_runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

Sequel.migration do
change do
# Mysql requires us to remove foreign key constraint
# before dropping column (errno 150). Sequel also
# requires type=foreign_key to be present for such operations.
if self.class.name.match /mysql/i
alter_table :apps do
drop_constraint :fk_apps_framework_id, :type => :foreign_key
drop_constraint :fk_apps_runtime_id, :type => :foreign_key
end
end

alter_table :apps do
drop_column :framework_id
drop_column :runtime_id
Expand Down

0 comments on commit 11f03e9

Please sign in to comment.