如何用不同的db模式管理git分支? [英] How to manage git branches with different db schemas?

查看:120
本文介绍了如何用不同的db模式管理git分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目需要处理一个新功能,这个功能需要重新设计数据库的一部分,同时让主开发分支继续处理旧模式。



管理这样一个项目的最佳做法是什么?



我想在创建新功能的同时拥有一个单独的数据库,但意识到这一点要求将数据库配置检入存储库,这是一个不可行的过程。还有其他方法可以解决这个问题吗?






种子数据以拯救



在发布这个答案之后,我发现了一个答案 - 我应该有一些脚本来填充我的数据库中的种子数据。这样我就可以在分支之间切换时删除/重新创建/播种数据库。

解决方案

解决这个问题的通常方法是检查您的数据库创建脚本到源代码控制。然后,您可以像其他源代码一样分支和管理它们。



您需要一种将代码指向特定数据库实例的方式(已使用当前分支中的脚本创建)。


I have a project where I need to work on a new feature that requires part of the database to be re-designed whilst also keeping the main development branch working on the old schema.

What is your best-practice for managing a project like this?

I thought about having a separate database whilst working on the new feature but realised this would require having the database config checked into the repository which is a no-go. Are there other ways I could approach the issue?


Seed data to the rescue

Right after posting this the answer hit me - I should have some scripts to populate my db with seed data. That way I can just drop/recreate/seed the database when switching between branches.

解决方案

The usual way to deal with this is to check your database creation scripts into source control. Then you can branch and manage them in the same way as the rest of your source code.

You will need a way of pointing your code at a particular instance of a database (which has been created using the scripts in the current branch).

这篇关于如何用不同的db模式管理git分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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