Nilay Singh
Nilay Singh

Reputation: 2331

How to rerun Migration in Rails

Hey I have an issue I am trying to do few things in rails. I am trying to edit the migration files to change few column and tables name. But I can see there is rollback option for this and reset but when I do rollback it require version and when I do reset drop or setup it loads the schema . Is there any way by which my application can run all the migration again and create new schema .

Upvotes: 2

Views: 1981

Answers (1)

margo
margo

Reputation: 2927

If you don't mind losing all the data, you can run

rake db:drop

BIG CAVEAT - this will delete your database and all your data.

Then you can run

rake db:create db:migrate 

If this is a new app, exists solely on your localhost i.e. has not been deployed to production, and you don't mind losing all your data, then this option is fine.

Generally, I would recommend not amending your migrations but creating new ones to change column names etc.

Upvotes: 7

Related Questions