executeCommand
The executeCommand
Change Type executes a system command.
Note: Using Liquibase commands such as migrateSQL
may not work as expected because the executeCommand
Change Type doesn't generate SQL. To resolve this, use Change Types that generate SQL.
Uses
You can typically use the executeCommand
Change Type to run a script using a specific executable. One reason to use executeCommand
is to insert or update data.
Running the executeCommand
Change Type
To execute a system command, follow these steps:
Step 1: Add the executeCommand
Change Type to your changeset with the needed attributes as it is shown in the examples.
Step 2: Deploy your changeset by running the update
command.
liquibase update
Available attributes
Name | Description | Required for | Supports |
---|---|---|---|
executable
|
The name of the executable to run | all | all |
os
|
The list of operating systems on which to execute the command (taken from the os.name Java system property) |
all | |
timeout
|
The timeout value for executable to run | all |
Nested properties
Name | Description | Required for | Supports | Multiple allowed |
---|---|---|---|---|
args / arg |
Arguments for the executable | all | yes |
Nested property attributes
Name | Description | Required for | Supports | Multiple allowed |
---|---|---|---|---|
value
|
The value of the attribute (for example: |
XML example
<changeSet author="liquibase-docs" id="executeCommand-example">
<executeCommand executable="mysqldump"
os="Windows 7"
timeout="10s">
<arg value="-out"/>
<arg value="-param2"/>
</executeCommand>
</changeSet>
YAML example
changeSet:
id: executeCommand-example
author: liquibase-docs
changes:
- executeCommand:
args:
- arg:
value: -out
- arg:
value: -param2
executable: mysqldump
os: Windows 7
timeout: 10s
JSON example
{
"changeSet":{
"id":"executeCommand-example",
"author":"liquibase-docs",
"changes":[
{
"executeCommand":{
"args":[
{
"arg":{
"value":"-out"
},
"arg":{
"value":"-param2"
}
}],
"executable":
"mysqldump",
"os":"Windows 7",
"timeout":"10s"
}
}]
}
}
Database support
Database | Notes | Auto rollback |
---|---|---|
DB2/LUW | Supported | No |
DB2/z | Supported | No |
Derby | Supported | No |
Firebird | Supported | No |
H2 | Supported | No |
HyperSQL | Supported | No |
INGRES | Supported | No |
Informix | Supported | No |
MariaDB | Supported | No |
MySQL | Supported | No |
Oracle | Supported | No |
PostgreSQL | Supported | No |
SQL Server | Supported | No |
SQLite | Supported | No |
Sybase | Supported | No |
Sybase Anywhere | Supported | No |