管理由 Git 操作创建的 schema.rb 中的冲突 [英] Managing conflict in schema.rb created by Git operation

查看:10
本文介绍了管理由 Git 操作创建的 schema.rb 中的冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个迁移,运行 rake db:migrate,这增加了我的 db/schema.rb 版本号.然后我做了一个 git fetch origin master 并看到我的团队成员发生了变化.所以我做了一个 git stash 和一个 git rebase FETCH_HEAD,然后是一个 git stash pop.这导致 db/schema.rb 中的版本号发生冲突.

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?

谢谢,最大

推荐答案

如果您当前的数据库具有正确的架构,您应该:

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

  • 运行挂起的迁移(如果有)

  • Run pending migrations (if any)

rake db:migrate

  • 从您当前的数据库架构覆盖您的 schema.rb

    rake db:schema:dump
    

  • 并提交

  • And commit

    这篇关于管理由 Git 操作创建的 schema.rb 中的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆