Frage

We have a post deployment script in our visual studio database project. It populates lookup tables with data. The problem is that every time we change schema and generate update script, post deployment script gets appended to the end of the deployment script. Is there a way to mark specific post deployment scripts in VS2010 to run only once?

War es hilfreich?

Lösung

Disclaimer: I am from ReadyRoll software which makes a commercial tool for database deployment.

Neither the DataDude project system you are using nor the new SSDT projects support single-use scripts. The fact that these projects are declarative in nature means that, unless the tool has native support population of lookup tables with data (which it currently does not), the operation can only be performed using a "run always" Post-Deployment script.

If you're not using it already, you might consider using the MERGE statement for your lookup data deployments, if you're deploying to SQL Server 2008 or higher. This gives you a somewhat declarative way of populating tables in that you don't have to check whether the data is already inserted before deploying.

If you'd like to try a project system that runs each script only once, you may like to consider the imperative approach (sometimes referred to as migrations). There is plenty of OSS around that does this, however you may like to consider ReadyRoll because of the fact that it integrates with Visual Studio: http://ready-roll.com

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top