I don't want to add schema.rb
to .gitignore
, because I want to be able to load a new database schema from that file. However, keeping it checked in is causing all sorts of spurious conflicts that are easily resolved by a fresh db:migrate:reset
.
Basically I want a way to:
There would be one or two people responsible for updating schema.rb
and knowing that it was correct.
Is there a way I can have my cake and eat it, too?
What has worked really well for me is to delete and .gitignore schema.rb
and then have it regenerated for each developer when they rake db:migrate
.
You can still achieve what you wanted without migrating from 0 and risking broken migrations from years ago by simply doing a "roll-up" of the migrations periodically. You can do this by:
rake db:migrate
schema.rb
in the ActiveRecord::Schema.define
blockdef up
(overwriting what's already there)Now your initial_schema migration is your starting point for new systems and you don't have to worry about conflicts in schema.rb
that may not be resolved correctly. It's not magical, but it works.