You don't need status
in the migrate command:
rake db:migrate
should be enough.
You are actually getting an error from rake
because of having status in the command:
rake aborted!
Don't know how to build task 'status'
EDIT
Following our discussion I now understand more.
The migration Demographics
has already been applied to the database in the past. This is proved by its 14 digit datetime being included in the schema_migrations
table.
Migrations are designed to be run once only. They make a change to the database (schema and/or data) and you move on.
When you run rake db:migrate
it finds any migration not yet applied to the database (in datetime order from the migration filename), applies it, then puts an entry for the datatime in schema_migrations
. Any migration which already has an entry in schema_migrations
is ignored.
If you want to make a further change to the database - even to a table created in a previous migration - you should create a new migration, and then use bin rake db:migrate
to apply it.
Yes you can backout a previously applied migration - rake db:rollback
. Rollbacks will apply in the reverse order the migrations were applied, ie. working backwards from the end of schema_migrations
. By default it will only back out the last migration, although you can use the STEP
parameter to do more (rake db:rollback STEP=3
for example).
You can also redo a previously applied migraton - rake db:migrate:redo
- again with optional STEP parameter. This is really just a shortcut for rollback followed by migrate.
RECOMMENDATION
My recommendation to you would be to put the Demographics
migration file back to the way it was before you made the change. This is important in case the migrations need to be all reapplied in the future.
I would now create a new migration to apply the changes to your table:
rails generate migration UseForiegnKeysInDemographics
Make the required alterations; you only need mention the changes to the table:
e.g.
class UseForiegnKeysInDemographics < ActiveRecord::Migration
def change
remove_column :demographics, :race
remove_column :demographics, :other_race
remove_column :demographics, :education
remove_column :demographics, :other_education
add_column :demographics, :race_id, :integer
add_column :demographics, :other_race_id, :integer
add_column :demographics, :education_id, :integer
add_column :demographics, :other_education_id, :integer
end
end
And apply this new migration:
rake db:migrate
I suggest you have a read of the Rails guide on migrations; http://guides.rubyonrails.org/migrations.html as it explains everything better than my brief summary.
Footnote:
As you want to add foreign keys to the demographics table, you might want to consider add_reference
instead of add_column
. I didn't include this in my example above because I don't know the details of your other tables, but it's well documented in the Rails guide.