Should I flatten Rails migrations?
Asked Answered
B

3

9

It's possible to replace db/migrate/* with the contents of db/schema.rb, so that you only have one migration step.

Do any of you ever do this? Why?

Bascomb answered 15/12, 2009 at 20:2 Comment(0)
E
5

Why would you want to do this? You could just run rake db:schema:load if you don't want to run all migrations. Migrations are used not (only) to initialize a new database, but to migrate it to another version.

Ecphonesis answered 15/12, 2009 at 20:6 Comment(1)
Because there are times where old migrations and code changes are no longer compatible. Then you can't run all migrations from scratch w/o hacking the old ones.Interne
E
3

Also, some big Ruby on Rails kit packages (like that one that's slipping my mind now that lets you set up an ecommerce site in your Rails app), flatten their migrations.

I've also known of projects with a ton of migrations to do this every once in a while to reduce the amount of time it takes to run rake db:migrate start to finish (say, on the continuous integration server)

Extragalactic answered 15/12, 2009 at 22:36 Comment(1)
That would be the spree project. They've been talking about flattening their migrations recentlyLorinalorinda
F
1

You can do rake db:schema:load to import the entire schema in one step. This is recommended, as opposed to running a ton of migrations.

Fremantle answered 15/12, 2009 at 20:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.