1. Copy the DLM Automation step templates to=
your Octopus Deploy library
After you've copied the DLM Automatio=
n step templates to your Octopus Deploy library, they're available whenever=
you add a process step in an Octopus Deploy project:
- Go to the DLM Automation step templates =
on the Octopus Deploy library website.
- In this example, we'll use the "Redgate - Create Database Release" and =
"Redgate - Deploy from Database Release" step templates.
Click on the "Redgate - Create Database Release" template.
- Click Copy to clipboard:
You're now ready to paste the script from your clipboard into your =
Octopus Deploy library:
- In Octopus Deploy, at the top of the page, click Library=
strong>.
- On the Step templates tab, click Import.
- In the Import window, paste the copied template into the empty field.=
li>
- Click Import.
- Click Save.
- Repeat steps 1 to 5 to copy the "Redgate - Deploy from Database Release=
" step template in the same way.
=
2. Create an Octopus Deploy project
- In Octopus Deploy, click Projects and <=
strong>All.
- Click Add project.
- In the Name field, enter Widget Dep=
loyment.
- Click Save.
You'll now add a series of deployment process steps to your Octopus Depl=
oy project.
3. Add=
the "Download and extract database package" step
This step picks up the NuGet package of the database schema you're going=
to deploy.
- Set up your NuGet package feed by doing one of the following:
- In the Widget Deployment project, on the&nbs=
p;Process tab, click Add step&n=
bsp;and select Deploy a NuGet package.
- In the Step name field, enter Downl=
oad and extract database package.
- In the Machine roles field, enter db-server and press Enter.
This must match the role y=
ou assigned to the Tentacle.
- In the NuGet feed field, select=
either the name of the external feed you registered when you&nb=
sp;set up your NuGet feed, or the Octopus Server (bui=
lt-in) repository.
- In the NuGet package ID field, =
enter the name of the package without the version number. For example,=
if the package was called WidgetShopLatest.0.1.nupkg, you'd =
only enter Widget.
When the package is generated,=
NuGet package manager automatically adds a number. If we included it here,=
Octopus would only deploy the package that matched that name and version n=
umber. By removing the number, we're telling Octopus to always look for the=
latest package with that name.
- In the Environments field, sele=
ct Production.
If you leave this blank, the step will be accessible to all environments.&=
nbsp;
- Click Save.
4. Add the "Create dat=
abase release" step
This step creates the database deployment resources, including the =
Update.sql script.
- On the project Process tab, click Add step and Redgate - Create Database Release.
- In the Machine roles field,=
enter db-server and press Ent=
er.
This must match the role you assigned to the=
Tentacle.
- In the Export path fie=
ld, enter the path the database deployment resources will be exp=
orted to.
This path will later be used in the "Deploy from =
Database Release" step. It must be accessible to all tentacles used in data=
base deployment steps.
- In the Database package step =
strong>field, select Download and extract database pa=
ckage.
- In the Target SQL Server instance&nb=
sp;field, enter the fully qualified SQL Server instance for =
the database you're deploying to.
- In the Target database name fie=
ld, enter the name of the database you're deploying to.
- In the Username (optional) and&=
nbsp;Password (optional) fields, enter the SQL Server username and password used to connect to =
the target database.
If you leave these blank, Windows authentica=
tion will be used to connect to the target database.
- In the Environments field, select P=
roduction.
If you leave this blank, the step will be accessible to all environments.&=
nbsp;
- Click Save.
5. Add the "Review database deployment resources" step
This step pauses deployment to let you review the database deployment re=
sources, including the Changes.html report, before allowing deployment to g=
o ahead.
- On the project Process tab, click =
Add step and select Manual intervention =
required.
- In the Step name field, enter Revie=
w database deployment resources.
In the Instructions field, copy and paste=
this text:
Please =
review the schema and static data changes, warnings and SQL change script i=
n 'Changes.html'.
In the Environments field, select Production.
If you leave this blank, the s=
tep will be accessible to all environments.
Click Save.
6. Add the=
"Deploy from database release" step
This step uses the database depl=
oyment resources to deploy the database changes.
- On the project Process tab, click Add step and select Redgate - Deploy from Dat=
abase Release.
- In the Machine roles field, enter =
db-server and press Enter.
This must match the role you assigned to the Tentacle.
- In the Export path<=
/strong> field, enter the path the database deployment resources =
will be exported to.
This must match the export path you entered i=
n 4. Add the 'Create database release' step.&nb=
sp;
- In the Database package step=
field, select Download and extract databas=
e package.
- In the Target SQL Server instance&nb=
sp;field, enter the fully qualified SQL Server instance for the database yo=
u're deploying to.
- In the Target database name field, enter the=
name of the database you're deploying to.
- In the Username (optional) and =
Password (optional) fields, enter =
the SQL Server username and password used to connect to the target dat=
abase.
If you leave these blank, Windows authentication will be used to connect t=
o the target database.
- In the Environments field, select P=
roduction.
If you leave this blank, the step will be accessible to all environments.&=
nbsp;
- Click Save.
You've finished setting up the project steps. The Process tab should loo=
k like this:
=
p>
7. Create a re=
lease
Now all the steps are set up, you can run your deployment process to cre=
ate a release:
Create a blank database called WidgetProduction:
- Open SQL Server Management Studio (SSMS).
- Click New Query.
Execute the following SQL query to create the database: =
p>
CREATE D=
ATABASE WidgetProduction
GO
USE WidgetProduction
GO
- In the Widget Deployment project, on the&nbs=
p;Process tab, click Create release.
This page lets you add an optional release note.
- Click Save.
- Click Deploy to Production (or if there's mo=
re than one environment, click Deploy and select=
Production).
- Click Deploy Now.
As the deployment process runs, Octopus Deploy shows the task progress lis=
t. The deployment pauses so you can review the database deployment resource=
s:
- Click Changes.html to download the Change re=
port.
Use the report to review the update script, warnings, and d=
etails of what'll be added, removed or modified if you go ahead with deploy=
ment.
- In Octopus Deploy, click assign to me and, i=
n Notes, enter a comment to say=
you've reviewed the database deployment resources.
- If you're happy with the report, click Proceed.
When the deployment is complete, the Task progress page looks like this:
You've now completed the deployment of the database package.
What now?
Other DLM Automation step templates are available on the Octopus Deploy Library we=
bsite:
- "Redgate - Deploy from Database" deploys the schema of a source da=
tabase to a target database without a review step.
- "Redgate - Deploy from Package" deploys a NuGet package containing=
a database schema to a target database without a review step.
For more information, see Octopus Deploy step templates reference.