2011-06-03 218 views
4

我在Linux上使用Liquibase,有没有人知道如何从Linux提示符一步一步地运行datbasechangelog.xml文件?数据库更新日志背后的想法及其工作原理是什么?如何在Linux系统上运行liquibase

回答

3

对于我们的项目,我们已经设置了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> 

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

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

liquibasetasks.properties

db.changelog.file=YOUR_MIGRATION_FILE.xml 

################################# 
## DB Settings 
################################# 
database.driver= 
database.username= 
database.password= 
database.url= 

好了,现在我们有蚂蚁任务设置和配置。与所有的拯救,你应该能够通过在命令提示符处键入以下运行迁移:

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

希望有所帮助!

相关问题