javadatabase-migrationmaven-pluginliquibase

Liquibase generate change log on db based on table name prefix


Can I generate Liquibase changelog from a DB based on table name prefix.

Example: If I have a DB schema and it has following tables:

abc
abcd
abcdef
xyz

I just want to generate ChangeLog for tables starting with "abc". So changelog for tables

abc, abcd, abcdef

Can someone help me if there's a way to do this?


Solution

  • This works for me on Windows 10:

    liquibase.properties:

    changeLogFile=dbchangelog.xml
    classpath=C:/Program\ Files/liquibase/lib/mysql-connector-java-8.0.20.jar
    driver=com.mysql.cj.jdbc.Driver
    url=jdbc:mysql://localhost:3306/liquibase?serverTimezone=UTC
    username=root
    password=password
    schemas=liquibase
    includeSchema=true
    includeTablespace=true
    includeObjects=table:persons
    

    C:\Users\username\Desktop>liquibase generateChangeLog

    Liquibase Community 4.0.0 by Datical
    Starting Liquibase at 11:34:35 (version 4.0.0 #19 built at 2020-07-13 19:45+0000)
    Liquibase command 'generateChangeLog' was executed successfully.
    

    You can download mysql-connector here, find the generateChangeLog documentation here and more information on includeObjects here.