Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] DB migration scripts are not applied correctly when booting up docker-compose environment #178

Closed
xenry opened this issue Apr 25, 2021 · 4 comments
Labels
area: backend type: bug Something isn't working

Comments

@xenry
Copy link
Contributor

xenry commented Apr 25, 2021

Describe the bug
DB migration scripts are not applied correctly when booting up docker-compose environment

To Reproduce

  1. execute docker-compose up -d in root folder
  2. check logs from with docker-compose logs flyway
Attaching to podkrepi-flyway
podkrepi-flyway | Flyway Community Edition 7.8.1 by Redgate
podkrepi-flyway | ERROR: Skipping filesystem location:sql (not found).
podkrepi-flyway | WARNING: Connection error: The connection attempt failed. Retrying in 1 sec...
podkrepi-flyway | WARNING: Connection error: The connection attempt failed. Retrying in 2 sec...
podkrepi-flyway | Database: jdbc:postgresql://roach-lb:26257/app (PostgreSQL 9.5)
podkrepi-flyway | Creating schema "app" ...
podkrepi-flyway | Creating schema "campaign" ...
podkrepi-flyway | Creating schema "account" ...
podkrepi-flyway | Creating Schema History table "app"."flyway_schema_history" ...
podkrepi-flyway | Current version of schema "app": null
podkrepi-flyway | Schema "app" is up to date. No migration necessary.
  1. check cockroachdb ui at http://localhost:3080

image

Expected behavior
sql migration scripts from db/migrations folder should be applied and we should have the relevant tables in the ui

@xenry xenry added type: bug Something isn't working area: backend labels Apr 25, 2021
@kachar
Copy link
Member

kachar commented Apr 25, 2021

@xenry I'm not able to reproduce the issue on master branch by running

$ docker-compose run --rm flyway

Starting podkrepi-roach-init ... done
Creating podkrepi_flyway_run ... done
Flyway Community Edition 7.5.4 by Redgate
Database: jdbc:postgresql://roach-lb:26257/app (PostgreSQL 9.5)
Successfully validated 7 migrations (execution time 00:00.024s)
Current version of schema "app": 4.0.0.1
Schema "app" is up to date. No migration necessary.


$ docker-compose run --rm flyway info
Starting podkrepi-roach-init ... done
Creating podkrepi_flyway_run ... done
Flyway Community Edition 7.5.4 by Redgate
Database: jdbc:postgresql://roach-lb:26257/app (PostgreSQL 9.5)
Schema version: 4.0.0.1

+-----------+---------+------------------------------+--------+---------------------+---------+
| Category  | Version | Description                  | Type   | Installed On        | State   |
+-----------+---------+------------------------------+--------+---------------------+---------+
|           |         | << Flyway Schema Creation >> | SCHEMA | 2021-04-06 14:35:35 | Success |
| Versioned | 1.0.0.1 | db                           | SQL    | 2021-04-06 14:35:35 | Success |
| Versioned | 1.0.0.2 | schemas                      | SQL    | 2021-04-06 14:35:35 | Success |
| Versioned | 2.0.0.1 | table contacts               | SQL    | 2021-04-06 14:35:35 | Success |
| Versioned | 2.0.0.4 | table support requests       | SQL    | 2021-04-06 14:35:35 | Success |
| Versioned | 3.0.0.1 | table users                  | SQL    | 2021-04-06 14:35:35 | Success |
| Versioned | 4.0.0.1 | table campaigns              | SQL    | 2021-04-06 14:35:35 | Success |
+-----------+---------+------------------------------+--------+---------------------+---------+

image

Which .env file variables are you using, my result is with .env.example which loads both docker-compose.yml and docker-compose.dev.yml

COMPOSE_FILE=docker-compose.yml:docker-compose.dev.yml # unix
COMPOSE_FILE=docker-compose.yml;docker-compose.dev.yml # windows

@kachar
Copy link
Member

kachar commented Apr 25, 2021

After the extra context in discord the issue might be related to WSL and docker

docker/compose#4852
https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly#ensure-volume-mounts-work


However you can try to manually disable the volumes section in docker-compose.dev.yml so the flyway migrations are used directly from the image without volume remapping.

https://github.com/daritelska-platforma/frontend/blob/0a4289c33e322a46d47f1cb44a205e6390269822/docker-compose.dev.yml#L48-L53

@xenry
Copy link
Contributor Author

xenry commented Apr 26, 2021

@xenry
Copy link
Contributor Author

xenry commented Apr 27, 2021

so it seems that the recommended way is to copy over the source to be inside wsl rather than mounting it from windows. Also be careful to remove any previously built flyway images which will be broken if built from code mounted on windows.

@xenry xenry closed this as completed Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: backend type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants