Applies to:
- Liquibase Pro
- Liquibase Open Source (Community)
Conditions:
- Liquibase Pro and Open Source versions prior to v4.24.0
- Snowflake
Issue Summary:
When using the liquibase.databaseChangelogTableName and liquibase.databaseChangelogLockTableName parameters to set custom names for the Liquibase tracking tables (DATABASECHANGELOG and DATABASECHANGELOGLOCK) with mixed case values (i.e. "DATABASECHANGELOG_customName"), the tables are successfully created the first time, but subsequent Liquibase commands fail with the below error message.
Error Message:
SEVERE [liquibase.integration] SQL compilation error:
Object 'DATABASECHANGELOG_customName' already exists. [Failed SQL: (2002) CREATE TABLE DATABASECHANGELOG_customName (ID VARCHAR(255) NOT NULL, AUTHOR VARCHAR(255) NOT NULL, FILENAME VARCHAR(255) NOT NULL, DATEEXECUTED TIMESTAMP_NTZ NOT NULL, ORDEREXECUTED INT NOT NULL, EXECTYPE VARCHAR(10) NOT NULL, MD5SUM VARCHAR(35), DESCRIPTION VARCHAR(255), COMMENTS VARCHAR(255), TAG VARCHAR(255), LIQUIBASE VARCHAR(20), CONTEXTS VARCHAR(255), LABELS VARCHAR(255), DEPLOYMENT_ID(10))]
liquibase.exception.CommandExecutionException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: SQL compliation error:
Object 'DATABASECHANGELOG_customName' already exists. [Failed SQL: (2002) CREATE TABLE DATABASECHANGELOG_customName (ID VARCHAR(255) NOT NULL, AUTHOR VARCHAR(255) NOT NULL, FILENAME VARCHAR(255) NOT NULL, DATEEXECUTED TIMESTAMP_NTZ NOT NULL, ORDEREXECUTED INT NOT NULL, EXECTYPE VARCHAR(10) NOT NULL, MD5SUM VARCHAR(35), DESCRIPTION VARCHAR(255), COMMENTS VARCHAR(255), TAG VARCHAR(255), LIQUIBASE VARCHAR(20), CONTEXTS VARCHAR(255), LABELS VARCHAR(255), DEPLOYMENT_ID(10))]
Example
Parameter value:
liquibase.databaseChangelogTableName=DATABASECHANGELOG_customName
Table name created:
DATABASECHANGELOG_CUSTOMNAME
Root Cause:
The tables are created in Snowflake in all uppercase, regardless of the mixed case value supplied. There is a known underlying bug causing Liquibase to keep the mixed case value when checking if the tracking tables have been created, which is not successful. This causes Liquibase to interpret this as the tracking tables needing to be created.
When trying to run the SQL needed to create the tracking tables, it fails since the tables already exist.
This issue was addressed by Liquibase in version 4.24.0.
Resolution:
Upgrade Your Version of Liquibase
To fix this issue without changing any property values, you can upgrade to Liquibase 4.24.0 or higher.
Update the Parameter Value Casing
Without upgrading, you can work around this issue by updating the values for both the liquibase.databaseChangelogTableName and liquibase.databaseChangelogLockTableName parameters to match the casing of these created tables in your database, which is likely all uppercase.
Comments
0 comments
Article is closed for comments.