Running all change-logs in a same transaction option for better deployment process

Hello, right now as a default behavior Liquibase commits transactions after each changelog. If there are multiple changesets for migration from version A to B and if one of the changesets fails, then the database will be in an inconsistent state neither version A nor version B can be deployed.

I am aware that for some databases due to DDL auto-commit, clean transactional migration may not be possible. But it is possible some other databases like PostgreSQL and all DDL and DML scripts can be combined in the same transaction and whenever one script is failed, all migrations scripts will be rolled back and the previous version can be deployed immediately.

So I am looking for a customization flag for migration to run all changesets in the same transaction for a better deployment process. Actually in Flyway group flag is used for this purpose. I like to use Liquibase and this will be a good enhancement.

Thanks in advance.

Hi Sir,

I suggest that you can achieve the same by making different changelog files for different versions.

Thanks for the answer.

Actually, we have lots of squads and developers. We have parallel main feature development branches. Also, the application is deployed in different environments during different levels of the software development cycle like dev, demo, so different file creation for each version will not be working for us.

I went through the same situation in my company. The solution is to use the “update-sql” command with the “–output-file=script.sql” parameter.

This way I can execute it directly in the database, controlling the transaction.

The good thing about this command is that it also generates the inserts in the dabasechangelog table, so Liquibase knows which changesets were executed.