使用Spring进行H2 DB和Flyway DB迁移

时间:2017-03-24 04:11:47

标签: spring-boot h2 flyway

正在学习我正在创建一个使用H2数据库使用spring boot存储表的简单应用程序。我正在使用flyway从JAVA程序迁移/创建一个新表。我在' application.properties'中指定了以下属性。文件:

logging.level.org.springframework.web=DEBUG
server.port=8080

spring.h2.console.enabled=true
spring.h2.console.path=/h2

spring.datasource.url=jdbc:h2:file:~/dasboot
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.driver

spring.datasource.max-active=10
spring.datasource.max-idle=8
spring.datasource.max-wait=10000
spring.datasource.min-evictable-idle-time-millis=1000
spring.datasource.min-idle=8
spring.datasource.time-between-eviction-run-millis=1

flyway.baseline-on-migrate=true
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.shows-sql=true

以下是H2 am使用的查询(V2__create_shipwreck.sql)。此查询位于 src / main / resources / db / migration 目录下,并使用maven包装:

CREATE TABLE SHIPWRECK(
    ID INT AUTO_INCREMENT,
    NAME VARCHAR(255),
    DESCRIPTION VARCHAR(2000),
    CONDITION VARCHAR(255),
    DEPTH INT,
    LATITUDE DOUBLE,
    LONGITUDE DOUBLE,
    YEAR_DISCOVERED INT
    );

在最终输出控制台中,我希望有一个' SCHEMA_VERSION'和我的#SHIPWRECk'表。但我什么都没得到: H2 Console Output

如果有人可以帮我解决问题,那就太好了。

0 个答案:

没有答案