schema.rb由于其他分支中的迁移而搞砸了

Vik*_*kko 16 ruby-on-rails schema.rb rails-migrations

目前我正在使用庞大的rails应用程序和多个分支,每个分支都有一个新功能.它发生了很多功能需要迁移,在将它与master合并之前应该不会出现问题:schema.rb已经使用dev数据库的信息进行了更新!

澄清:

1. Branch A has migration create_table_x
2. Branch B has migration create_table_y
3. Branch A adds another create_table_z and runs db:migrate
4. You want to merge Branch A with Master and you see table_x, table_y and table_z in the schema.rb of Branch A.
Run Code Online (Sandbox Code Playgroud)

在分支中的每次迁移之前重置+种子数据库或为每个分支创建数据库都不是一个选项.由于2 GB SQL数据的巨大规模,它将无法使用.

我的问题:

是否真的需要将schema.rb保留在存储库中,因为每次迁移都会重建它?

如果是这样,是否可以从迁移而不是数据库转储构建架构?

Ste*_*yen 10

你应该在你的仓库中保留架构.运行迁移将修复schema.rb文件中的合并冲突.我简单地回答你的问题

  1. 这是必需的吗?不是真的,而是良好的做法.

"强烈建议将此文件检入您的版本控制系统." -schema.rb

  1. 有可能的?是的,但您可能想问自己是否真的通过这样做来节省任何时间,无论是手动还是从其他地方的迁移构建模式并将其推入.

你获得了额外的好处

rake db:schema:load
Run Code Online (Sandbox Code Playgroud)

rake db:schema:dump
Run Code Online (Sandbox Code Playgroud)

http://tbaggery.com/2010/10/24/reduce-your-rails-schema-conflicts.html