我们有gradle的db迁移插件吗?

时间:2012-10-09 12:42:52

标签: gradle

我正在将maven项目转换为gradle。在maven中,他们使用了c5-db-migration插件。我们在gradle中有这样的东西吗?

3 个答案:

答案 0 :(得分:2)

您可以使用Flyway Ant Tasks。 还有一个gradle插件正在工作(测试状态)。

示例:

configurations {
    flyway
}

task flywayMigrate(dependsOn: "build") << {
    ext.flyway_classpath = files(sourceSets.main.output.resourcesDir) + files(configurations.flyway)
    ant.taskdef(name: 'flywayMigrate', classname: 'com.googlecode.flyway.ant.MigrateTask', classpath: ext.flyway_classpath.asPath)
    ant.flywayMigrate(driver: 'oracle.jdbc.driver.OracleDriver', url: 'myurl', user: 'myusername', password: 'mypassword',
            encoding: 'Cp1252', baseDir: 'sql')
}

dependencies {
    compile "com.googlecode.flyway:flyway-core:1.7"
    compile "com.oracle:ojdbc6:11.2.0.1.0"
    flyway "com.oracle:ojdbc6:11.2.0.1.0"
    flyway "com.googlecode.flyway:flyway-ant:1.7"
}

答案 1 :(得分:1)

我写了一篇你可以找到@(https://github.com/katta/gradle-flyway-plugin)

最简单的用法如下所示

buildscript {
  repositories {
    mavenCentral()
    maven {
        url uri('http://katta.github.com/repository')
    }
  }
  dependencies {
    classpath 'org.katta.gradle.api.plugins:flyway:1.3'
    classpath 'postgresql:postgresql:9.1-901.jdbc4'
  }
}

apply plugin: 'flyway'

## replace properties with the values with your database settings
flyway {
    driver='org.postgresql.Driver'
    url='jdbc:postgresql://127.0.0.1/flyway' 
    user='postgres'
    password='s#cRet'
}

文档here详细说明了如何使用它。如果您在使用它时遇到任何问题,请告诉我。

答案 2 :(得分:0)

有一个用于gradle的liquibase插件,由tim berglund撰写。该插件可在github上找到:https://github.com/tlberglund/gradle-liquibase-plugin

也许这有助于你。

欢呼声, 勒

相关问题