Update SQL step
Last updated on
The Update SQL step generates the SQL statements that would be applied to a target database from your Liquibase changelog, without executing them. It is used for validation, auditing, and policy enforcement before a deployment runs. The generated SQL is surfaced in the Harness UI and can be referenced in downstream approval gates and OPA policy steps.
note
The Update SQL step is a Liquibase-only step. It is not available for Flyway migrations.
Add the Update SQL step
- In Harness, go to Database DevOps and select your project.
- Open your pipeline and select the stage where you want to preview SQL.
- Select Add Step and choose Update SQL.
- Configure the step parameters described below.
- Select Apply Changes, then save and run the pipeline.
Step parameters
- Name - Display name for the step. The step ID is derived from this name.
- Timeout - Maximum duration before the step times out. Default is
10m. - Container Registry - Select the container registry connector that Harness uses to pull the migration container.
- Select DB Schema - Choose the DB Schema that holds your changelog and migration definitions.
- Select DB Instance - Choose the DB Instance against which the SQL preview will be generated.
Use the SQL output in downstream steps
The generated SQL is available as a step output expression. Use this to pass the preview SQL into an approval gate or OPA policy step:
<+execution.steps.{stepGroupIdentifier}.steps.{stepIdentifier}.output.sqlCommands>
For example, if the step group is stepGroup1 and the step identifier is UpdateSQL_1:
<+execution.steps.stepGroup1.steps.UpdateSQL_1.output.sqlCommands>
Next steps
- Go to Apply DB Schema step to apply the reviewed changesets to your database instance.
- Go to Using OPA with Database DevOps to configure OPA policies that evaluate the generated SQL before deployment.