Liquibase changelog parameters in liquibase.properties

ε祈祈猫儿з 提交于 2019-12-05 06:37:29

It is possible to put changelog parameters in liquibase.properties, or a custom --defaultsFile. Reading the source indicates that you must prefix the properties with "parameter.".

Your error probably looks something like this:

SEVERE 11/4/16 10:26 AM: liquibase: Unknown parameter: 'read_only_user'
liquibase.exception.CommandLineParsingException: Unknown parameter: 'read_only_user'
    at liquibase.integration.commandline.Main.parsePropertiesFile(Main.java:453)

Example liquibase.properties:

driver=oracle.jdbc.driver.OracleDriver
url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost)(PORT=1600))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=devdb)))"
username=scott
password=tiger
defaultSchemaName=app_admin
promptOnNonLocalDatabase=false
parameter.read_only_user=app_read

Using the parameter in a changeset:

<changeset author="Ryan" id="1">
  <sql>GRANT SELECT ON APP.SOME_TABLE TO ${read_only_user}</sql>
</changeset>

Yes, and is very usefull if you want to manage information under control...like passwords in differents enviroments: liquibase.properties:

parameter.pass_admin=idonthavepassword

and the changelog:

<changeSet author="rbs" id="create_user_admin" labels="inicial">
    <preConditions onFail="CONTINUE">
    <sqlCheck expectedResult="0">SELECT COUNT(1) FROM pg_roles WHERE rolname='admin'</sqlCheck>
    </preConditions>
    <sql>CREATE USER admin PASSWORD '${pass_admin}' LOGIN SUPERUSER NOCREATEDB NOCREATEROLE INHERIT NOREPLICATION CONNECTION LIMIT -1
        <comment>Creating admin user</comment>
    </sql>
</changeSet>

Yes, it is possible: http://www.liquibase.org/documentation/liquibase.properties.html. And use --defaultsFile to pass property file.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!