Execute Arbitrary SQL Commands
Learn how to execute arbitrary SQL commands using the Liquibase command step in Harness DB DevOps for flexible database operations.
Pre-requisites
Liquibase command step is created. You can refer to the Harness documentation detailing how to Add a Liquibase command step
Overview
Using the LiquibaseCommand step we can execute arbitrary SQL commands using the execute-sql command. This allows users to define raw SQL, simplifying workflows that require direct SQL execution.
Use Cases
This is useful when we to run a single SQL statement without creating a separate changelog file.
Examples include:
Performing one-time data fixes
Executing a quick schema modification
Running DDL/DML queries during a deployment pipeline
check the database data
Pipeline Configuration
The command value for LiquibaseCommand Step needs to be
execute-sqlExclude ChangeLog Filecheckbox needs to checkedThe settings configuration will contain key as
sqland value will contain the sql statement to execute
The configuration in the pipeline will look like below

At the yaml level the configuration will look like below
Conclusion
If everything is configured correctly, the step execution should look like below.
In the below example we are querying from DATABASECHANGELOG table where description is matching a certain value.

References
Next steps
Go to Add a Liquibase command step to learn how to add a Liquibase command step in your pipeline.
Last updated
Was this helpful?