runInTransaction
The runInTransaction
attribute specifies whether a changeset can be run as a single transaction (if possible). The default value is true
.
Uses
When you make a database deployment with the update command, Liquibase attempts to create an atomic "transaction block" around each changeset to ensure that it is either fully deployed to the database or not deployed at all. This protects your database from incomplete deployments with unpredictable behavior.
However, your database may not allow certain SQL statements to run in a transaction block, such as CREATE DATABASE
in PostgreSQL or ALTER TABLE
on an external table in AWS Redshift. If you need to deploy a changeset where this is the case, set runInTransaction
to false
on that changeset.
Warning: If runInTransaction
is set to false
and an error occurs part way through running a changeset that contains multiple statements, the Liquibase DATABASECHANGELOG table will be left in an invalid state.
Syntax
Note: All changelog attributes use the camelCase
format.

-- changeset your.name:1 runInTransaction:false
CREATE DATABASE myDatabase;

<changeSet id="1" author="your.name" runInTransaction="false">
<sql>CREATE DATABASE myDatabase;</sql>
</changeSet>

databaseChangeLog:
- changeSet:
id: 1
author: your.name
runInTransaction: false
changes:
- sql:
sql: CREATE DATABASE myDatabase;

{
"changeSet": {
"id": "1",
"author": "your.name",
"runInTransaction": "false",
"changes": [
{
"sql": {
"sql": "CREATE DATABASE myDatabase;"
}
}
]
}
}