- Task
- Version ยท 6.0.2
- Create
Decorate paired Up and Down migration scripts
Last updated: November 17, 2026
Some tools, such as Entity Framework, generate each migration as an Up script and a Down script, where the Down script reverses the whole Up script rather than each statement. Pass both to decorate-sql with --rollback-file to get one changeset whose rollback is the Down script.
Before you begin
Liquibase Secure must be installed, with your license key applied. See Apply your license key.
To deploy the changelog, Liquibase needs a connection to your database. Set
url,username, andpasswordinliquibase.properties, asLIQUIBASE_COMMAND_*environment variables, or with--url,--username, and--password. See Connect Liquibase to your database.You need the Up and Down scripts for one migration as SQL files, written for Oracle or SQL Server.
--rollback-fileworks with a single--sql-file, so decorate each pair in its own run. To decorate scripts that have no Down script, see Decorate a folder of SQL scripts.
Procedure
Export the Up and Down scripts
Export the migration's Up and Down scripts as SQL files from your migration tool. This article uses an Entity Framework migration named InitialCreate:
Migrations/20260630153331_InitialCreate.Up.sqlMigrations/20260630153331_InitialCreate.Down.sql
Liquibase reads a byte order mark (BOM) to decode each file and does not copy it into the changelog. A file without a BOM is read as UTF-8, or as the encoding you set with the global --file-encoding parameter.
Choose how the changeset runs
On SQL Server, decide whether the changeset runs through JDBC or through sqlcmd:
Through JDBC. Omit
--executor. Liquibase stripsGObatch separators from the changeset body so it runs cleanly through JDBC.Through sqlcmd. Set
--executor=sqlcmdwhen the scripts rely onGO. Liquibase keeps the separators, and the changeset runs through the native client.
Run decorate-sql with --rollback-file
Pass the Up script as --sql-file and the Down script as --rollback-file. Liquibase skips statement classification and writes a single changeset: the whole Up script becomes the change body, and the whole Down script becomes its rollback.
Both files are read as opaque blocks, so --rollbackSQL markers inside them are not interpreted, and Liquibase warns if it finds one. The transaction control checks that decorate-sql runs on a single script do not run in this mode.
Check the rollback in the changelog
How the rollback is stored depends on the output format. XML, YAML, and JSON embed the rollback SQL inline. Formatted SQL instead writes a pointer to the Down file, so that file stays independently runnable with sqlcmd or sqlplus without stripping any comment prefixes:
-- rollbackSqlFile path:Migrations/20260630153331_InitialCreate.Down.sqlA relative --rollback-file path is written as you passed it and resolves against the search path when you run update. An absolute path is rewritten relative to the changelog's folder and marked relativeToChangelog:true, so the changelog stays portable.
Deploy the changelog
liquibase update --changelog-file=changelog.mssql.sql