-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[api] fix the old migration the right way
See receipt 13 in http://pragprog.com/book/rr2/rails-recipes
- Loading branch information
Showing
3 changed files
with
20 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class RemoveDevelProject < ActiveRecord::Migration | ||
class DbPackage < ActiveRecord::Base; end | ||
def up | ||
packs = DbPackage.where("develproject_id is not null").all | ||
|
||
unless packs.empty? | ||
puts packs.inspect | ||
raise "Migrate to 2.3 first and run ./script/migrate_devel_projects" | ||
end | ||
|
||
execute("alter table db_packages drop FOREIGN KEY db_packages_ibfk_2") | ||
remove_column :db_packages, :develproject_id | ||
|
||
end | ||
|
||
def down | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains 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