My environment is SQL Server 2019 and Liquibase 4.8.0
I'm having troubles using runWith=sqlcmd within a changeset. Liquibase responds with:
Attribute 'runWith' is not allowed to appear in element 'changeSet'
However, looking at the documentation, and the examples (near the bottom), here: https://docs.liquibase.com/concepts/changelogs/attributes/using-sqlcmd-integration.html
...it seems to be saying that the "runWith" attribute should be within the changeSet tag
liquibase.properties
classpath=C:\\Program Files\\Microsoft SQL Server\\sqljdbc_10.2\\enu\\mssql-jdbc-10.2.0.jre8.jar
driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
url=jdbc:sqlserver://localhost:1433;database=SSReporting;Enlist=false
liquibaseSchemaName=dbo
username=deploy_dbbuild
password=xxxxxxx
changeLogFile=changelog.xml
liquibase.hub.mode=off
integratedSecurity=false
liquibase.sqlcmd.args=-v db_to_use=SSReporting
liquibase.sqlcmd.keep.temp=true
liquibase.sqlcmd.keep.temp.name=liq.log
liquibase.sqlcmd.path=C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn
liquibase.sqlcmd.timeout=-1
changelog.xml
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd" >
<changeSet id="sqlcmd_test" runWith="sqlcmd" runOnChange="true" author="smcintosh" >
<sqlFile path="sqlcmd_test.sql" relativeToChangelogFile="true" />
</changeSet>
</databaseChangeLog>
Check that sqlcmd is where I think it is:
C:\> where sqlcmd
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\SQLCMD.EXE
sqlcmd_test.sql
DECLARE @foobat int;
GO
Trying it out...
####################################################
## _ _ _ _ ##
## | | (_) (_) | ##
## | | _ __ _ _ _ _| |__ __ _ ___ ___ ##
## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ ##
## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ ##
## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| ##
## | | ##
## |_| ##
## ##
## Get documentation at docs.liquibase.com ##
## Get certified courses at learn.liquibase.com ##
## Free schema change activity reports at ##
## https://hub.liquibase.com ##
## ##
####################################################
Starting Liquibase at 13:53:48 (version 4.8.0 #1581 built at 2022-02-18 21:43+0000)
Liquibase Version: 4.8.0
Liquibase Pro 4.8.0 by Liquibase licensed to Liquibase Pro Evaluation until Tue Mar 29 19:00:00 EDT 2022
WARNING! Your license will expire in 5 days!
To renew Liquibase Pro please contact sales@liquibase.com or go to https://www.liquibase.org/download
Unexpected error running Liquibase: Error parsing line 8 column 86 of changelog.xml: cvc-complex-type.3.2.2: Attribute 'runWith' is not allowed to appear in element 'changeSet'.
For more information, please use the --log-level flag```