【问题标题】:How to run liquibase on linux system如何在 linux 系统上运行 liquibase
【发布时间】:2015-01-28 05:20:43
【问题描述】:

我在 Linux 上使用 Liquibase,有谁知道如何从 Linux 提示符逐步运行 datbasechangelog.xml 文件? databasechangelog 背后的想法是什么以及它是如何工作的?

【问题讨论】:

    标签: liquibase


    【解决方案1】:

    对于我们的项目,我们设置了 ant 任务来执行此操作。因此,例如,如果您想运行迁移,ant 文件可能如下所示:

    ant-migrations.xml

    <project name="Migrations" basedir="." default="update-database">
    <property file="./liquibasetasks.properties" />
    
    <path id="master-classpath" description="Master classpath">
        <fileset dir="..\lib">
            <include name="*.jar" />
        </fileset>
    </path>
    
    <target name="update-database">
        <fail unless="db.changelog.file">db.changelog.file not set</fail>
        <fail unless="database.url">database.url not set</fail>
    
        <fail unless="database.username">database.username not set</fail>
        <fail unless="database.password">database.password not set</fail>
    
        <taskdef resource="liquibasetasks.properties">
            <classpath refid="master-classpath"/>    
        </taskdef>
    
        <updateDatabase
                changeLogFile="${db.changelog.file}"
                driver="${database.driver}"
                url="${database.url}"
                username="${database.username}"
                password="${database.password}"
                promptOnNonLocalDatabase="${prompt.user.if.not.local.database}"
                dropFirst="false"
                classpathref="master-classpath"
        />
    
    </target></project>
    

    确保在 classpath 元素中引用了您的 liquibase jar 文件。

    属性文件包含特定于您的环境的引用:

    liquibasetasks.properties

    db.changelog.file=YOUR_MIGRATION_FILE.xml
    
    #################################
    ## DB Settings
    #################################
    database.driver=
    database.username=
    database.password=
    database.url=
    

    好的,现在我们已经设置和配置了 ant 任务。所有这些都保存了,您应该能够通过在命令提示符下键入以下内容来运行迁移:

    linux>ant -f ant-migrations.xml update-database
    

    希望有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-31
      • 2015-01-01
      • 1970-01-01
      • 2021-03-10
      • 1970-01-01
      相关资源
      最近更新 更多