Please sign in to comment.
Now run the migration generator $ hobo generate migration You'll see that the migration generator considers this change to be ambiguous. Whenever there are columns removed *and* columns added, the migration generator can't tell whether you're actually removing one column and adding another, or if you are renaming the old column. It's also pretty fussy about what it makes you type. We really don't want to play fast and lose with your precious data, so to confirm that you want to drop the 'status' column, you have to type in full: "drop status". Once you've done that you'll see that the generated migration includes the creation of the new foreign key and the removal of the old status column. Press `g` now to generate the migration without running it.
- Loading branch information...
Showing with 23 additions and 0 deletions.
|@@ -0,0 +1,23 @@|
|class AddStoryStatusModel < ActiveRecord::Migration|
|create_table :story_statuses do |t||
|add_column :stories, :status_id, :integer|
|remove_column :stories, :status|
|add_index :stories, [:status_id]|
|remove_column :stories, :status_id|
|add_column :stories, :status, :string|
|remove_index :stories, :name => :index_stories_on_status_id rescue ActiveRecord::StatementInvalid|