Applies to:
- Liquibase Pro
- Liquibase Open Source (Community)
Conditions:
- Any version of Liquibase Pro or Open Source
Issue Summary:
No changes were made when attempting to run a Liquibase command that would insert or delete entries into/from the DATABASECHANGELOG table (e.g., update, tag, rollback, etc.).
When checking the database that Liquibase is connecting to, the DATABASECHANGELOG and DATABASECHANGELOGLOCK tables do not exist.
Error Message:
In both cases, Liquibase will not error, but the expected schema/database that should have the DATABASECHANGELOG and DATABASECHANGELOGLOCK tables modified is not modified.
Potential Root Causes:
The root cause is that Liquibase is not connecting to the expected database/schema.
Troubleshooting:
There are various commands that can be used to determine what database and schema Liquibase uses for the DATABASECHANGELOG and DATABASECHANGELOGLOCK table.
Determine which schema Liquibase is using:
If a schema isn't specified, Liquibase will use a pre-defined default schema, which depends on the database in use. For example, when connecting to a Postgres database and not specifying the schema, Liquibase will use the public
schema.
There are two Liquibase parameters that control what schema Liquibase will use: liquibase-schema-name and default-schema-name.
-
- The liquibase-schema-name parameter specifies the schema in which the DATABASECHANGELOG and DATABASECHANGELOGLOCK tables will be stored.
- The default-schema-name can be used to change the default schema Liquibase uses. This value determines what schema the SQL will be deployed to.
Review the SQL Liquibase will deploy
The updateSQL command will show the exact SQL that Liquibase will deploy to the database. This includes what schemas are being set and if the database's context is being switched.
This command also shows the Liquibase queries that are used on the DATABASECHANGELOG and DATABASECHANGELOGLOCK tables, which include the schema used for these two tables.
Below is the updateSQL output for a Postgres database where the Liquibase project doesn't specify the schema. Liquibase places the pre-defined default schema, public
, in the query.
-- Lock Database
UPDATE public.databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = '', LOCKGRANTED = NOW() WHERE ID = 1 AND LOCKED = FALSE;
History command
Another helpful command to validate the DATABASECHANGELOG table Liquibase is using is the history command, which will query the DATABASECHANGELOG table Liquibase is connected to and display the results to the console.
Related Article(s):
N/A
Comments
0 comments
Article is closed for comments.