Search code examples
gitrepositorytfsbuildredgate

redgate database dependencies


I'm new to Redgate and looking for some help on how best to setup my database repository.

I have multiple sites and multiple databases, they all have their own repositories. A database can be associated with one or more sites.

I've created my repositories in the following way;

wwwroot/webapps/site1
wwwroot/webapps/site2
wwwroot/webapps/site3

wwwroot/databases/db1
wwwroot/databases/db2
wwwroot/databases/db3
wwwroot/databases/db4

For example, site1,2,3 all use db1 but site2 is also associated with db2. The changes that happen against db1 apply to all the sites but I want to be able to check in my changes to db1 irrespective of which site repository I'm working on.

All this works just fine when creating builds to each individual repository but I want to deploy my code and db changes as part of the same build.

At the moment, I have a TFS builds (TFS 2015 and using task based build) that deploy my code and I have to make sure any associated DB changes are deployed separately as part of another build.

Is it possible to somehow link my code build to a database change have them deploy together? Is my repository setup correct or is there a better way to set this up? Any guidance would be greatly appreciated.

More info to describe my issue.

    Code repository
wwwroot/webapps/site1/feature_A
wwwroot/webapps/site1/feature_B
wwwroot/webapps/site2/feature_C

    DB repository
wwwroot/databases/db1/feature_A
wwwroot/databases/db1/feature_C

Using the above example;

feature_A (code repository) is dependent on feature_A (DB repository). The current setup will require me to create two build one for my Code and the other for my DB.

feature_B (code repository) has no dependencies

feature_C (code repository) is dependent on feature_C (DB repository).

I can only create a build by specifying a feature, as my Code and DB repositories are separate I'm forced to do this in two builds.

I would like to achieve the above by creating one build that will push my DB and Code changes out at the same time. I don't know how best to do this or if it's possible. If it's not possible can someone suggest an alternative.

I would not like to add the DB repository inside my web folder because the same database is used across multiple websites and this will cause problems.

For example the following will work for me but it means the DB1 repository will be created multiple times.

wwwroot/webapps/site1\Code\
wwwroot/webapps/site1\DB1\

wwwroot/webapps/site2\Code\
wwwroot/webapps/site2\DB1\
wwwroot/webapps/site2\DB2\

wwwroot/webapps/site3\Code\
wwwroot/webapps/site3\DB1\ 

Solution

  • So you want to get two repository in one build. You can check the steps below:

    1. In the build definition, specify one repository:

    enter image description here

    1. Then add a command line task to use git command to clone another repository to the same location as step 1:

    enter image description here

    If there is authorization issue when you clone repository, enable "Allow Scripts to Access OAuth Token":

    enter image description here