Options

Set up migration scripts to work with branching

MckMurrayMckMurray Posts: 37 Bronze 3
Hi, I'm trying to understand how migration scripts need to be configured in order to work with the following scenario:

In TFS, my branching structure is as follows:
- Production (Rev. 1000)
    - Dev (Rev. 1000)

And I have two databases linked to these two branches respectively.

The scenario is, I am developing on a longer-term project in the Dev branch and committing my changes as I go, including creating migration scripts.
Each time I commit my changes to Dev, it gets a new revision number (from the TFS changeset number), so after a few changes I have:
- Production (Rev. 1000)
    - Dev (Rev. 1023)

When it comes time to deploy my changes to Production, my migration scripts will be picked up as long as the revision number of the target database has not changed (i.e. the revision number is earlier than the "from" revision of my migration scripts).

However, sometimes I need to make a hotfix on Production. If I commit that hotfix against Production, it now has a later revision than my Dev branch:
- Production (Rev. 1024)
    - Dev (Rev. 1023)

Any subsequent attempts to deploy from Dev to Production will ignore the migration scripts.

This seems like it must be a common scenario - is there a way to make it work?

Tx

Comments

  • Options
    Hey MckMurray,

    Thanks for posting in the forums!
    In this case it would probably be best to deploy backwards (Using Compare, from Prod to Dev) so that Dev has all of the hotfixes that are currently on Prod. Alternatively you could restore a backup of Prod in your Dev environment. Either of those methods would make the revision numbers equal again (v1024 in your example).

    I have also followed up with you via email and please let me know if you have any questions or issues with the above!

    Kind Regards,
    AP
    Andrew Pierce
    Technical Sales Engineer
    Redgate Software
Sign In or Register to comment.