简体   繁体   English

使用核心/模型数据库在不同的安装上进行小的更改进行定制,而无需重复代码

[英]Using core/model database with small changes on different installations for customization without duplicating code

As an example core database looks like this:例如,核心数据库如下所示:

Person  - Id, FirstName, LastName
Address - Id, Street, ZipCode

This model is used on the majority of the installations but for a couple of installations I want to add customized columns, let's say the column State to Address for Customer X and BirthDate to Person for Customer Y.此模型用于大多数安装,但对于一些安装,我想添加自定义列,假设列State to Address for Customer X 和BirthDate to Person for Customer Y。

Now, I don't want to add these columns to the core database because the State column is only used by our US customers and the BirthDate is only used by our European customers were BirthDate is obligatory ( NOT NULL ) and would therefore need a dummy value for all the other customers.现在,我不想将这些列添加到核心数据库中,因为State列仅由我们的美国客户使用,而BirthDate仅由我们的欧洲客户使用,因为BirthDate是强制性的( NOT NULL ),因此需要一个虚拟对所有其他客户的价值。

I was checking in GitHub about having several branches - Core and US-Customer - but that would mean that the whole Core solution would be copied over to the US-Customer branch but when the Core branch is changed it would not update the US-Customer branch ie having to maintain basically two repositories.我在 GitHub 上检查了关于有几个分支 - CoreUS-Customer - 但这意味着整个Core解决方案将被复制到US-Customer分支,但是当Core分支发生更改时,它不会更新US-Customer分支即必须维护基本上两个存储库。

Is it possible to have this sort of customization either in SQL Data Tools or in GitHub were the customized solutions (eg US-Customer ) would only have the absolutely necessary changes and without SQL Data Tools throwing errors in Visual Studio about missing tables or any other error?是否有可能在SQL Data ToolsGitHub进行这种自定义,如果自定义解决方案(例如US-Customer )只会进行绝对必要的更改,并且SQL Data Tools不会在Visual Studio抛出有关丢失表或任何其他错误错误?

Example:例子:

Core branch Core分支

Person  - Id, FirstName, LastName
Address - Id, Street, ZipCode

US-Customer branch US-Customer分公司

ALTER TABLE Address ADD State CHAR(2) NOT NULL

EU-Customer branch EU-Customer分公司

ALTER TABLE Person ADD BirthDate DATE NOT NULL

There is no very easy way of implementing so.没有很容易实现的方法。 If you wish to do that completely in SSDT way, then you need to create several projects:如果您希望以 SSDT 方式完全做到这一点,那么您需要创建几个项目:

  • ProjectCore --> will have all shared objects. ProjectCore --> 将拥有所有共享对象。 It shouldn't have references to the projects below;它不应该引用以下项目;
  • ProjectUS --> will have all the objects for US and reference ProjectCore as The same database ; ProjectUS --> 将拥有 US 的所有对象并将ProjectCore引用为The same database
  • ProjectEU --> will have all the objects for EU and reference ProjectCore as The same database . ProjectEU --> 将拥有 EU 的所有对象,并将ProjectCore引用为The same database

Both ProjectUS and ProjectEU will have their own publish profiles. ProjectUSProjectEU都有自己的发布配置文件。 You'll have put full definition of different objects there, not just ALTER statements.您将在那里放置不同对象的完整定义,而不仅仅是 ALTER 语句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM