Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails, Git and adding migrations

sometimes when working in rails, I work on several things at once using git branches

sometimes, I'd like to test new ideas by implementing them and testing how and if they work accordingly. This involves sometimes adding models and migrations.

When switching branches, however, the migrations were already migrated to the DB and they stay, causing problems later on..

Is there a way to work with several branches and each to have different migration files, and before starting to work on a branch to "soft reset" the db only to the current migration files without losing data?

like image 789
Nick Ginanto Avatar asked Apr 01 '26 17:04

Nick Ginanto


1 Answers

Normally, in development, I need some sample data that I keep in seed.rb which enables me to recreate the db, its structure and the sample data with a rake task.

Another thing I did was to keep more than one database. I would then just manually change the entry in database.yml according to the current git branch.

like image 70
moritz Avatar answered Apr 03 '26 07:04

moritz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!