Don’t delete your migrations!

Rails migration pushing issues

Say you deleted a migration so when you push all your migration histories to heroku

it gives you migration errors.

You can type

rake db:migrate:status

This will give you history of migrations and whats missing,

 Status   Migration ID    Migration Name

————————————————–

   up     20150207013411  ********** NO FILE **********

   up     20150207020939  Create users

   up     20150207021329  Add user id to posts

   up     20150207022740  Create comments

   up     20150207023755  Create categories

   up     20150207063021  Add columns to users

   up     20150207075531  Create post categories

   up     20150208061306  Add column to posts

   up     20150217172541  Add pass word digest to users

   up     20150305203015  Create votes

   up     20150309223946  Add column to comments

  down    20150313162219  Create posts

you can then copy that migration ID and create a new file in your migrations with that migration ID number, and code inside the file.

This will put that code in the proper place so you can run migrations smoothly on heroku or locally.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: