在运行时在Java代码中运行flyway迁移 [英] Run flyway migrations inside Java code during runtime
本文介绍了在运行时在Java代码中运行flyway迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够在运行时在Java代码中运行Flyway迁移,有没有办法实现这一目标?我似乎无法在文档中找到它.我正在使用SQLite数据库(如果这很重要).
I want to be able to run Flyway migrations inside my Java code during runtime, is there a way of achieving this? I can't seem to be able to find it in the docs. I'm using a SQLite database (if this matters at all).
推荐答案
Flyway::migrate()
致电 Flyway::migrate
.
Flyway::migrate()
Call 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();
}
}
这篇关于在运行时在Java代码中运行flyway迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文