Spring Boot AutoConfigure封装了两种类型的数据库版本控制工具:flyway和liquibase。简单比较了一下,flyway要方便很多。
flyway.enabled=true # Enable flyway. flyway.encoding= # flyway.baseline-on-migrate= true# flyway.baseline-description= # flyway.baseline-version=1 # version to start migration flyway.url= # JDBC url of the database to migrate. If not set, the primary configured data source is used. flyway.user= # Login user of the database to migrate. flyway.password= # JDBC password if you want Flyway to create its own DataSource flyway.schemas= # schemas to update flyway.table= schema_version# flyway.target=迁移时使用的目标版本,默认为latest version,也就是全部脚本文件都执行 flyway.out-of-order= # flyway.init-sqls= # SQL statements to execute to initialize a connection immediately after obtaining it. flyway.check-location=false # Check that migration scripts location exists. flyway.clean-on-validation-error= # flyway.validate-on-migrate= # flyway.ignore-failed-future-migration= # flyway.locations=classpath:db/migration # locations of migrations scripts flyway.placeholder-prefix= # flyway.placeholder-replacement= # flyway.placeholder-suffix= # flyway.placeholders.*= # flyway.sql-migration-prefix=V # flyway.sql-migration-separator= # flyway.sql-migration-suffix=.sql #
flyway.baseline-on-migrate: true flyway.baseline-version: 0.1.0.2 flyway.baseline-description: sdfs
Spring Boot 1.5.6.RELEASE的flyway.baseline-version属性不管用;
placeholders 提供了类似freemaker的模板功能,可以在脚本中写入 create table ${foo1}; 在flyway.setPlaceholders(map->{map.put(“foo1”,“table1”)}),替换脚本中的foo1 =》 table1
Flyway:简单的数据库迁移工具 Official Documentation Spring Boot Official Documentation flyway在spring boot中的使用 Flyway学习笔记
