synonyms and deployment.
spakh
Posts: 7
I have synonyms defined in my database that differ in their definitions depending on which server the database is installed. For example, on my dev and test servers, one of the synonym is defined as:
CREATE SYNONYM [dbo].[SYN_TMAGENT] FOR [TPSSYNC].[ANDRXTST].[AGID06USR].[TMAGENT]
On the production server the synonym is dfined as:
CREATE SYNONYM [dbo].[SYN_TMAGENT] FOR [TPSSYNC].[TPS].[AGID06USR].[TMAGENT]
When my developers sync with source control on their development systems they need to have the first definition. When deploying changes to the test server, the same definition is used as in the dev server. When database changes are deployed to production, the synonym must be defined by the latter definition.
How can I set this up using SQL Source Control where this is done without manual intervention.
CREATE SYNONYM [dbo].[SYN_TMAGENT] FOR [TPSSYNC].[ANDRXTST].[AGID06USR].[TMAGENT]
On the production server the synonym is dfined as:
CREATE SYNONYM [dbo].[SYN_TMAGENT] FOR [TPSSYNC].[TPS].[AGID06USR].[TMAGENT]
When my developers sync with source control on their development systems they need to have the first definition. When deploying changes to the test server, the same definition is used as in the dev server. When database changes are deployed to production, the synonym must be defined by the latter definition.
How can I set this up using SQL Source Control where this is done without manual intervention.
Comments
Unfortunately this feature doesn't exist right now, but I think it would be great if you could post it here:
http://redgate.uservoice.com/forums/390 ... ce-control
This way others can vote it up and hopefully we'll be able to justify implementing it. In the meantime I guess the best bet is to run a post deployment script that corrects these differences. It's not ideal, but I can't think of a better option.
David Atkinson
Red Gate
Product Manager
Redgate Software
If you have any alternative suggestions on how you would like for us to solve this, we'd be interested in hearing your ideas.
David
Product Manager
Redgate Software
I added the suggestion to the uservoice forum.
http://redgate.uservoice.com/forums/390 ... ?ref=title
My thinking was to have the source control plug-in somehow provide a mechanism to select a different object script based on target server, and manage the underlying source code for each defintion seamlessly. Maybe this is better addressed in a CI type of environment where other tools provide this functionality. I am not sure at this time.
In the meantime I will look at the new Migration Scripts feature of Source Control and see if that provides a satisfactory solution.
Is that something that would work for you?
David
Product Manager
Redgate Software
So, I was hoping for the SQL Source Control to provide mechanism where different synonym definitions can be assigned to the same object and extract the appropriate one depending on the target environment. Maybe there is a better solution. Possibly through CI (continuous integration). We currently do not have CI setup for our database changes, but it is on the wish list .
Have you tried using SQL Source Control's filter feature so that synonyms don't accidentally get checked into SVN? Right click on the db in the Object Explorer and then select Other SQL Source Control tasks > Edit filter rules... Then, uncheck synonyms on the left and save and close. Now, the synonyms should not show up on the commit list anymore so developers don't have to remember to deselect them every time they commit.
Make sure you commit the filter configuration so other developers stop seeing the synonyms on their commit lists too.
I hope this helps!
Stephanie M. Herr :-)
Product Manager Database DevOps