Skip to content

1000kit/tkit-liquibase-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tkit-liquibase-plugin

1000kit liquibase maven plugin to generate the DIFF of the postgresql database.

License Maven Central GitHub Actions Status

The plugin will execute this steps:

  1. Start docker two postgresql container.
  2. Start the Hibernate entity manager with create-drop flag. This will apply all the Hibernate changes to the target database.
  3. Apply existing Liquibase changes to the source database. If there is not changeLog file in the src/main/resource/db directory the update will be not execute.
  4. Compare the source and target database. The result of the execution will be in the target/liquibase-diff-changeLog.xml file.

Maven configuration

Generate database diff

Create a profile in your maven project.

 <profile>
    <id>db-diff</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.tkit.maven</groupId>
                <artifactId>tkit-liquibase-plugin</artifactId>
                <version>latest-version</version>
                <executions>
                    <execution>
                        <id>default</id>
                        <goals>
                            <goal>diff</goal>
                        </goals>
                        <phase>compile</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>

Run maven command in the project directory:

mvn clean compile -Pdb-diff

The result of the execution will be in the target/liquibase-diff-changeLog.xml file.

Check liquibase changes

Create a profile in your maven project.

 <profile>
    <id>db-check</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.tkit.maven</groupId>
                <artifactId>tkit-liquibase-plugin</artifactId>
                <version>latest-version</version>
                <executions>
                    <execution>
                        <id>default</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <phase>validate</phase>
                        <configuration>
                            <skipChanges>
                                <dropTable>table1,table2</dropTable>
                                <createTable>newTable</createTable>
                            </skipChanges>
                        </configuration>                        
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>

After you run db-diff run maven command in the project directory:

mvn clean compile -Pdb-diff
mvn clean compile -Pdb-check

Check command will validate target/liquibase-diff-changeLog.xml file.