从docker-compose中使用时,flyway无法接收迁移 [英] flyway not picking up migrations when used from docker-compose

查看:99
本文介绍了从docker-compose中使用时,flyway无法接收迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的docker-compose.yml文件中提供以下服务:

I have the following service in my docker-compose.yml file:

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

我的资源包中只有一个迁移:

And I have just one migration in my resources package:

当我使用docker compose运行服务时(docker-compose up -d --build flyway)flyway创建flyway_schema_history表,但不创建迁移中定义的表.如果我查看日志,则会看到以下消息:

When I run the service with docker compose (docker-compose up -d --build flyway) The flyway creates the flyway_schema_history table but doesn't create the table defined in the migration. If i check the logs i see this message:

Boxfuse数据库提供的

Flyway Community Edition 5.2.4:jdbc:postgresql://yurldb:5432/yurldb(PostgreSQL 10.13)成功已验证0个迁移(执行时间00:00.011s)的当前版本模式"public":<<空模式>>模式"public"是最新的.不迁移是必需的.

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是正确的(否则会出现某种语法错误).它只是没有检测到该迁移.有什么主意吗?

The migration is not triggered. Why is that? I am not sure what I am missing. I have the migrations in the correct package and also the SQL inside is correct(else there would be some sort of syntax error). It just doesn't detect that migration. Any idea?

更新我只是注意到,当我运行该命令时,在包结构中会创建一个小目录.不知道是什么:

update I just noticed that when i run that command a little directory is created in the package structure. Not sure what it is:

我还要添加另一张图片以显示项目的整体结构:

I am also adding another picture to show also the overall structure of the project:

更新2 使用卷映射 ./src/main/resources/db.migration:/flyway/sql 在我的包结构中生成了另一个目录:

update 2 Using the volume mapping ./src/main/resources/db.migration:/flyway/sql generated an additional directory in my package structure:

推荐答案

将映射更改为此./src/main/resources/db/migration:/flyway/sql

使用 db.migration 导致Docker使用该名称创建,Intellij仅显示目录 db/migration 像包名称 db.dmigration 如果db目录中仅包含目录.

Using db.migration causes Docker to create with that name, Intellij just shows the directory db/migration like a package name db.dmigration if the db directory has only directories in it.

这篇关于从docker-compose中使用时,flyway无法接收迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆