从 docker-compose 使用时,flyway 不接收迁移
flyway not picking up migrations when used from docker-compose
我的 docker-compose.yml 文件中有以下服务:
flyway:
image: boxfuse/flyway:latest-alpine
command: -url=jdbc:postgresql://yurldb:5432/yurldb -schemas=public -user=postgres -password=somepassword migrate
networks:
- yunet
volumes:
- ./flyway:/flyway/sql
restart: on-failure
depends_on:
- yurldb
我的资源包中只有一个迁移:
当我 运行 使用 docker 组合服务时(docker-compose up -d --build flyway)
flyway 创建 flyway_schema_history table 但不会创建迁移中定义的 table。如果我检查日志,我会看到这条消息:
Flyway Community Edition 5.2.4 by Boxfuse Database:
jdbc:postgresql://yurldb:5432/yurldb (PostgreSQL 10.13) Successfully
validated 0 migrations (execution time 00:00.011s) Current version of
schema "public": << Empty Schema >> Schema "public" is up to date. No
migration necessary.
未触发迁移。这是为什么?我不确定我错过了什么。我在正确的包中进行了迁移,而且里面的 SQL 也是正确的(否则会有某种语法错误)。它只是没有检测到该迁移。有什么想法吗?
更新
我刚刚注意到,当我 运行 该命令时,在包结构中创建了一个小目录。不确定是什么:
我还添加了另一张图片来展示项目的整体结构:
更新 2
使用卷映射 ./src/main/resources/db.migration:/flyway/sql
在我的包结构中生成了一个附加目录:
将您的映射更改为此 ./src/main/resources/db/migration:/flyway/sql
使用 db.migration
导致 Docker 使用该名称创建,如果 db 目录只有目录它。
我的 docker-compose.yml 文件中有以下服务:
flyway:
image: boxfuse/flyway:latest-alpine
command: -url=jdbc:postgresql://yurldb:5432/yurldb -schemas=public -user=postgres -password=somepassword migrate
networks:
- yunet
volumes:
- ./flyway:/flyway/sql
restart: on-failure
depends_on:
- yurldb
我的资源包中只有一个迁移:
当我 运行 使用 docker 组合服务时(docker-compose up -d --build flyway) flyway 创建 flyway_schema_history table 但不会创建迁移中定义的 table。如果我检查日志,我会看到这条消息:
Flyway Community Edition 5.2.4 by Boxfuse Database: jdbc:postgresql://yurldb:5432/yurldb (PostgreSQL 10.13) Successfully validated 0 migrations (execution time 00:00.011s) Current version of schema "public": << Empty Schema >> Schema "public" is up to date. No migration necessary.
未触发迁移。这是为什么?我不确定我错过了什么。我在正确的包中进行了迁移,而且里面的 SQL 也是正确的(否则会有某种语法错误)。它只是没有检测到该迁移。有什么想法吗?
更新 我刚刚注意到,当我 运行 该命令时,在包结构中创建了一个小目录。不确定是什么:
我还添加了另一张图片来展示项目的整体结构:
更新 2
使用卷映射 ./src/main/resources/db.migration:/flyway/sql
在我的包结构中生成了一个附加目录:
将您的映射更改为此 ./src/main/resources/db/migration:/flyway/sql
使用 db.migration
导致 Docker 使用该名称创建,如果 db 目录只有目录它。