Luchia Bloomfield
Luchia Bloomfield

Reputation: 89

add new column to table push to heroku

Following on from my previous post (carrierwave image not loading into source code), I've added a new column (feature_image) to my table portfolios.

I would like to push this to my Heroku app however I already have a number of portfolio entries on the website that I don't want to lose.

Is there anyway I can push my database changes without losing the content already on there?

Thank you!

Upvotes: 4

Views: 1729

Answers (1)

rmagnum2002
rmagnum2002

Reputation: 11421

pushing it will not affect your records (unless you have some special code that resets the db each time you do a push - never heard of such cases, but who knows), only new migration will be executed to add new column so you'll end up having lots of portofolios with no image.

rails app saves all migrations numbers into schema_migration table in db, so next time you'll run a migration it will migrate only the ones that are not in schema_migration.

in my case if I'll run migration only 20140109214830_add_is_new_to_messages will be migrated as its number is not schema_migration, it works this way on local machine and the same when pushing.

enter image description here

after migrating it, migration number will be saved into schema_migration table (line 44):

enter image description here

git push heroku master && heroku run rake db:migrate && heroku restart

Upvotes: 2

Related Questions