- Can I generate SQL without databasechangelog and databasechangeloglock table? I don't see any value in having the on the production environment?
WHY? The features of the liquibase are lying on these two tables. Liquibase uses the DATABASECHANGELOG table to track which changesets have been run.
The table tracks each changeset as a row, identified by a combination of the “id”, “author”, and “filename” columns. Liquibase uses the DATABASECHANGELOGLOCK table to ensure only one instance of Liquibase is running at one time. Basically, these two tables are used to help you do not run the same changeset again without your knowledge and provide a mechanism to stop the concurrent access.
2.In some change sets I have files that are in the root of the project, something like this:
When I run the app, the change sets are ran well, but when I try to run updateSQL I receive: ./liquibase/some-file.xml does not exist?
How did you configure the liquibase. In my case, I have configured the liquibase with spring boot & also added the liquibase gradle plugin.
Because of this relative path issue, what I have done is, changed the logicalFilePath of changelog as follow, and also used the relative path file.
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.4.xsd"
logicalFilePath="schema/15-01-changelog-comment-order-header-table.xml">
<changeSet id="10" author="sivaramr" dbms="postgresql" context="dev,qa,prod">
<changeset> ... </changeset>
</changelog>
When you configure the master changelog file don't configure the path as well instead of using the default path.
spring.liquibase.change-log=classpath:db/changelog/changelog-master.xml
- You can use tag to do that,
Version Control with liquibase
Tag command
The tag command is typically used to mark the current database state, version, release, or any other information by adding the tag to the last row in the DATABASECHANGELOG table
We can add a tag with changeset as follow for the database.
Before creating the tag we have to check that, the tag is ready there or not by following the liquibase command
./gradlew tagExists -PliquibaseCommandValue=v1.0.0
We can use the following command to add the tag to the last changeset of the database
./gradlew tag -PliquibaseCommandValue=v1.0.0
Rollback Tag Command
The rollback command is typically used to revert all changes that were made to the database after the tag you specify.
When you run rollback , Liquibase will roll back sequentially all the deployed changes until it reaches the tag row in the DATABASECHANGELOG table.
It is a best practice to run the rollbackSQL command that allows you to inspect for potential mistakes before running the command.
./gradlew rollback -PliquibaseCommandValue=v1.0.0