mysql - Best way to handle rails migrations across staging and production severs? -
i've taken on control of rails project, before took lead kind of being handled semi-technical manager not knows rails. in time realized needed add tables/rows database, added them through mysql , didn't create migrations them. when first took on added migrations tables/rows have them locally.
the issue when try run migrations on staging/production severs had tables added manually through mysql migration fails(because migrations added have updated tables/rows locally crashes due them existing). hasn't been issue add migration entirely new table, because of old ones crashing since tables exist, migration never gets ran.
to knowledge way fix drop tables , re-add them migrations wrote. reason i'm unsure i'd lose data in tables can't happen. there's way backup data , reload after drop tables , re-add them i've never done before wouldn't know start. alternatively manually update db in mysql add new table want , keep migrations local seems hacky , defeats purpose of using them.
so, ideas?
rails uses schema_migrations
table keep track of migrations run. has 1 column called version
last run migration's number.
select * schema_migrations;
one way update table migration number has changes applied database
Comments
Post a Comment