Generation of new database?
JDenman
Posts: 9 New member
I have a VSTS build (using Redgate DLM Automation: Build) that generates a nuget package and on a later step deploys to our instance of OctopusDeploy (that part is working). In OctopusDeploy, I'm using the 'Redgate - Deploy from Package' step to take that package and deploy to a server.
If the target SQL instance doesn't yet have the database, it'll fail to begin the step (as it cannot set the database/context). If my goal is to deploy all missing deltas to the target server, what step/process should I be using instead?
If the target SQL instance doesn't yet have the database, it'll fail to begin the step (as it cannot set the database/context). If my goal is to deploy all missing deltas to the target server, what step/process should I be using instead?
Tagged:
Comments
Note, add this create script in a parent or sister directory to your SQL Source Control directory. I try to avoid adding my own scripts to the directory you give to Redgate because you can confuse Redgate tools which are designed to parse all the sql scripts in that directory.
Then, I add a simple step in Octopus Deploy to run my IF NOT EXISTS CREATE DATABASE script before the "Redgate Deploy from Package" step. Then you know your DB will always exist. There is an Octopus Deploy step template to run a SQL script here:
https://library.octopusdeploy.com/step-templates/73f89638-51d1-4fbb-b68f-b71ba9e86720/actiontemplate-sql-execute-script
This step template asks you to type the script into the Octopus GUI but it does also accept variable substitution so you could package up your SQL scripts into a different NuGet and reference them from that variable.
DevOps Mentor and Coach
Director of DLM Consultants
Creator of Speaking Mentors
Microsoft Data Platform MVP
Friend of Redgate
Twitter / LinkedIn
Imagine I have version 1.0, 1.1, and 1.2 committed in my source control, and thus 3 packages in OctopusDeploy. Now I have a SQL server I want to promote these changes to. What's the best way to setup that deploy process so it gets up to date?
Does that help?
Redgate Software
@JDenham: Assuming you created your package from scripts maintained by SQL Source Control the package contains the desired state/model and the deployment, under the hood, will use SQL Compare to get the DB into the desired state. Hence, the NuGet packages do not contain your updates/migrations. These are worked out for you by the software.
Hence, as long as the database exists with the correct name you should not need any old packages.
DevOps Mentor and Coach
Director of DLM Consultants
Creator of Speaking Mentors
Microsoft Data Platform MVP
Friend of Redgate
Twitter / LinkedIn
Easy enough, just figured it had been done before.
Yes, that's correct.
Redgate Software