Applies to:
- Liquibase Pro
- Liquibase Open Source (Community)
Conditions:
All versions of Liquibase Pro and Liquibase Open Source
Question:
Why is my history/comment getting removed from my SQL script in the deployed location?
Answer:
A common practice when deploying SQL scripts is to include comments with the SQL to document additional information for the script itself.
Example
-- ======================================
-- author: lora
-- create date: 10/20/2023
-- description: This comment section will NOT be applied
-- ======================================
CREATE OR REPLACE FUNCTION TestFunction6() RETURNS trigger AS $proc$
-- inline comment 1 - will be applied (depending on "stripComments" value)
BEGIN
select count(1)
where emp_no = 123;
END
$proc$ LANGUAGE plpgsql;
After deployment, however, none of the comments are included in the deployed SQL in the target location.
The stripComments attribute can be used on changesets; however, it only applies to comments inside the SQL statement being run. Comments before or after the SQL statement will not be applied. The default value for stripComments is true.
XML Example
<changeSet author="liquibase-docs" id="sql-example">
<sql dbms="!h2, oracle, mysql"
endDelimiter="\nGO"
splitStatements="true"
stripComments="false">
-- ======================================
-- description: This comment section will NOT be applied
-- ======================================
CREATE OR REPLACE FUNCTION TestFunction6() RETURNS trigger AS $proc$
-- inline comment 1 - will be applied (depending on "stripComments" value)
BEGIN
select count(1)
where emp_no = 123;
END
$proc$ LANGUAGE plpgsql;
</sql>
</changeSet>
Formatted SQL Example
-- liquibase formatted sql
-- changeset lora:1 stripComments:false
-- ======================================
-- author: lora
-- create date: 10/20/2023
-- description: This comment section will NOT be applied
-- ======================================
CREATE OR REPLACE FUNCTION TestFunction6() RETURNS trigger AS $proc$
-- inline comment 1 - will be applied (depending on "stripComments" value)
BEGIN
select count(1)
where emp_no = 123;
END
$proc$ LANGUAGE plpgsql;
Comments
0 comments
Article is closed for comments.