Gitlab CI docker - No migrations found
UnknownGnome opened this issue · 2 comments
UnknownGnome commented
Trying to run flyway from Gitlab CI/CD. But not matter what I do I haven't been able to get it to find and use the migrations. I've been able to use the same code locally, but in my Gitlab runner it fails. I'm stuck.
I've tried
- leaving off the
-locations
part - mounting the volume to
sql
- using the
redgate/flyway
image - leaving off the
-schemas
- running
chmod 777 -R $FLYWAY_MIGRATIONS_PATH
before mounting
Simplified CI -
flyway_job:
services:
- docker:dind
variables:
FLYWAY_DOCKER_IMAGE: flyway/flyway:latest
FLYWAY_DOCKER_CONTAINER_NAME: flyway-container
FLYWAY_MIGRATIONS_PATH: $CI_PROJECT_DIR/migrations
script:
- docker pull $FLYWAY_DOCKER_IMAGE
- export JDBC=jdbc:postgresql://$DB_ENDPOINT:5432/$DB_NAME
- export FLYWAY_DOCKER_RUN="docker run --rm -v $FLYWAY_MIGRATIONS_PATH:/flyway/sql $FLYWAY_DOCKER_IMAGE -user=$DB_USER -password=$PGPASSWORD -schemas=public -locations=filesystem:/flyway/sql"
- $FLYWAY_DOCKER_RUN migrate -X -url=${JDBC} -cleanDisabled='true'
Debug log -
Flyway Community Edition 9.2.0 by Redgate
See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#9.2.0
DEBUG: AWS SDK available: false
DEBUG: Google Cloud Storage available: true
DEBUG: Scanning for filesystem resources at '/flyway/sql'
DEBUG: Scanning for resources in path: /flyway/sql (/flyway/sql)
DEBUG: Loading config file: /flyway/conf/flyway.conf
DEBUG: Unable to load config file: /flyway/flyway.conf
DEBUG: Unable to load config file: /flyway/flyway.conf
DEBUG: Using configuration:
DEBUG: flyway.cleanDisabled -> true
DEBUG: flyway.jarDirs -> /flyway/jars
DEBUG: flyway.locations -> filesystem:/flyway/sql
DEBUG: flyway.password -> ********
DEBUG: flyway.schemas -> public
DEBUG: flyway.url -> jdbc:postgresql://db_endpoint:5432/db_name
DEBUG: flyway.user -> dbadmin
DEBUG: Multiple databases found that handle url 'jdbc:postgresql://db_endpoint:5432/db_name': YugabyteDB, CockroachDB, PostgreSQL
DEBUG: Scanning for classpath resources at 'classpath:db/callback' ...
DEBUG: Determining location urls for classpath:db/callback using ClassLoader java.net.URLClassLoader@16e7dcfd ...
DEBUG: Unable to resolve location classpath:db/callback.
Database: jdbc:postgresql://db_endpoint:5432/db_name (PostgreSQL 13.6)
DEBUG: Driver : PostgreSQL JDBC Driver 42.4.1
DEBUG: DDL Transactions Supported: true
DEBUG: Schemas: public
DEBUG: Default schema: null
DEBUG: Scanning for SQL callbacks ...
DEBUG: Validating migrations ...
Successfully validated 0 migrations (execution time 00:00.030s)
WARNING: No migrations found. Are your locations set up correctly?
Current version of schema "public": << Empty Schema >>
Schema "public" is up to date. No migration necessary.
DEBUG: Memory usage: 48 of 120M
In my $CI_PROJECT_DIR/migrations
dir I have a file V1__Initial.sql
-
CREATE TABLE MyTable (
MyColumn VARCHAR(100) NOT NULL
);
DoodleBobBuffPants commented
Could you ls
the contents of FLYWAY_MIGRATIONS_PATH
just before the docker run, to ensure that the migrations are there in the job
DoodleBobBuffPants commented
Closing until further activity