Managing conflict in schema.rb created by Git operation

maxenglander picture maxenglander · Sep 30, 2011 · Viewed 22.8k times · Source

I created a migration, ran rake db:migrate, which bumped my db/schema.rb version number. Then I did a git fetch origin master and saw that there were changes from my team members. So I did a git stash and a git rebase FETCH_HEAD, followed by a git stash pop. This resulted in a conflict in db/schema.rb over the version number.

Upstream>>>
ActiveRecord::Schema.define(:version => 20110930179257) do
===========
ActiveRecord::Schema.define(:version => 20110930161932) do
<<<Stashed

I think the appropriate fix would be to manually increment the version number to something higher than the upstream.

Is this sensible, or bad news?

Thanks, Max

Answer

Wizard of Ogz picture Wizard of Ogz · Sep 30, 2011

If your current database has the correct schema, you should:

  • Run pending migrations (if any)

    rake db:migrate
    
  • Overwrite your schema.rb from your current database schema

    rake db:schema:dump
    
  • And commit