【发布时间】:2019-03-14 16:00:02
【问题描述】:
我希望能够在运行时在我的 Java 代码中运行 Flyway 迁移,有没有办法实现这一点?我似乎无法在文档中找到它。我正在使用 SQLite 数据库(如果这很重要的话)。
【问题讨论】:
-
@giorgiga 我一定错过了,但这正是我要找的。谢谢!
我希望能够在运行时在我的 Java 代码中运行 Flyway 迁移,有没有办法实现这一点?我似乎无法在文档中找到它。我正在使用 SQLite 数据库(如果这很重要的话)。
【问题讨论】:
Flyway::migrate()package foobar;
import org.flywaydb.core.Flyway;
public class App {
public static void main(String[] args) {
// Create the Flyway instance and point it to the database
Flyway flyway =
Flyway.configure()
.dataSource( "jdbc:h2:file:./target/foobar" , "scott" , "tiger" ) // (url, user, password)
.load() // Returns a `Flyway` object.
;
// Start the migration
flyway.migrate();
}
}
【讨论】: