Wednesday, November 29, 2017

ruby on rails add a column after a specific column name

I doubt it allowed you to actually rake db:migrate this migration, so you shouldn't have to roll back. Just remove the bottom three add_columns and replace the top one with
add_column :patient_allergies, :reaction_id, :integer, after: :patient_id
and it should be fine to migrate. For future reference, here's what that command you entered should look like:
rails generate migration add_reaction_id_to_patient_allergies reaction_id:integer
The space before integer made the generator think it was a new column. Sadly you can't use Ruby syntax (a => b) on the command line either.

No comments:

Post a Comment