liquibaseliquibase-sql

Liquibase GenerateChangeLog doesnt include schemaName in the changelog file


I am using the following command to generate the change log

liquibase --schemas=test_schema --changelog-file=changelog.xml generateChangeLog

My liquibase.properties file is following:

url: jdbc:postgresql://xx.xxx.xx.xx:5432/test_db
driver: org.postgresql.Driver
username: testuser
password: test
logFile: liquibase.log
logLevel: debug
defaultSchemaName= test_schema
outputDefaultSchema= true

The output in the changelog.xml doesnt have a schemaName, I have multiple schemas in my database so I need schemaname in the changelog as well.

Output :

<changeSet author="user1 (generated)" id="xxxxxxxxxxxxx-1">
        <createTable tableName="hello_world">
            <column name="msg" type="CHAR(60)"/>
        </createTable>
    </changeSet>

Should be test_schema.hello_world or schemaname should be defined. Any suggestions what I am doing wrong?


Solution

  • Try to append currentSchema= to your db url

    e.g. command line:

    --url="jdbc:postgresql://DB_HOST:DB_PORT/DB_NAME?currentSchema=SCHEMA_NAME"
    

    liquibase.properties

    url="jdbc:postgresql://DB_HOST:DB_PORT/DB_NAME?currentSchema=SCHEMA_NAME"
    

    then call

    liquibase <other command line params not part of liquibae.properties> generateChangeLog