Does Liquibase support dry run?

后端 未结 4 890
梦毁少年i
梦毁少年i 2020-12-17 21:24

We have couple of data schemas and we investigate the migration to Liquibase. (One of data schemas is already migrated to Liquibase).

Important question for us is if

4条回答
  •  独厮守ぢ
    2020-12-17 21:53

    If your Liquibase migration is sufficiently database agnostic, you can just run it on an in-memory H2 database (or some other "throwaway database") that you can spin up easily using a few lines of code.

    var info = new Properties();
    info.put("user", "sa");
    info.put("password", "");
    
    try (var con = new org.h2.Driver().connect("jdbc:h2:mem:db", info)) {
        var accessor = new FileSystemResourceAccessor();
        var jdbc = new JdbcConnection(con);
        var database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(jdbc);
    
        Liquibase liquibase = new Liquibase("/path/to/liquibase.xml", accessor, database);
        liquibase.update("");
    }
    

    I've blogged about this approach more in detail here.

提交回复
热议问题