Pre/Post Deployment Scripts

Compares and synchronizes SQL Server databases, backups and scripts.

Moderators: JonathanWatts, Chris Auckland, David Atkinson, eddie davis, Anu Deshpande, Michelle Taylor, alice.easey, james.billings, chengvoon.tong

Pre/Post Deployment Scripts

Postby SeriousM » Wed Jan 11, 2012 11:52 am

Hi,

we evaluate sql compare for azure db deployment and i wonder how i can add pre/post deployment scripts to the output?

do i need an additional product or do i miss something important?

thanks
SeriousM
 
Posts: 11
Joined: Mon Sep 27, 2010 9:28 am

Postby David Atkinson » Wed Jan 11, 2012 11:57 am

There's no provision in the the tool for this. Is there anything stopping you appying a separate script outside of SQL Compare?

I'm also interested to know what you intend to add to your pre and post deployment scripts.

Kind regards,

David Atkinson
Product Manager
Red Gate
David Atkinson
 
Posts: 1124
Joined: Mon Dec 05, 2005 4:54 pm
Location: Twitter: @dtabase

Postby SeriousM » Wed Jan 11, 2012 12:33 pm

This is simple:

Table before update:
Code: Select all
[User]
'Name' (contains "Test Dummy")


Table change:
Code: Select all
[User]
Rename 'Name' -> 'FirstName' (still contains "Test Dummy")
Add 'LastName' (defualt "not set")


Table after update:
Code: Select all
[User]
'FirstName', 'LastName'


Post deployment script:
Code: Select all
update [User]
set LastName = StringAfterFirstSpace(FirstName), FirstName = StringBeforeFirstSpace(FirstName)
where LastName = 'not set'


This is a silly simple example, but could occur.

Sure, i could execute this after i executed the schema update script, but i want to handle the whole update in a transaction.
SeriousM
 
Posts: 11
Joined: Mon Sep 27, 2010 9:28 am

Postby David Atkinson » Wed Jan 11, 2012 1:45 pm

I see.

You're making a change that SQL Compare itself can't handle, as you're splitting a column and SQL Compare's script wouldn't have the knowledge to preserve your data.

There's good news and bad news.

The good news is that we can handle that via the addition of custom migration scripts. There's a video that describes how this works here:
http://www.red-gate.com/products/sql-de ... deployment (it's the second one, called "A step by step guide through database deployment).

The bad news is that due to various implementation details this functionality doesn't work with SQL Azure. How often do you find yourself in situations where you need to add pre/post statements to your scripts? I think you'll have to carry on modifying SQL Compare's script manually for the time being, and hopefully we'll handle this in a later release.

David
David Atkinson
 
Posts: 1124
Joined: Mon Dec 05, 2005 4:54 pm
Location: Twitter: @dtabase

Postby SeriousM » Wed Jan 11, 2012 5:29 pm

Hi David,

thanks for the link to the video.

The migration script option is only available with the additional product "SQL Source Control 3.0" which we wont buy.

So we have to execute a custom pre/post deployment script and with this way we can handle the sql azure problem with ease.

Thanks!
SeriousM
 
Posts: 11
Joined: Mon Sep 27, 2010 9:28 am


Return to SQL Compare 10

Who is online

Users browsing this forum: No registered users and 0 guests