Unable to run flyway migration #1171
Replies: 4 comments
-
imho: see the doc in https://hub.docker.com/_/postgres
so try without the "localhost". |
Beta Was this translation helpful? Give feedback.
-
Thanks @ImreSamu for the pointers. I followed the exact pattern from the #474 issue and still getting unknown host exception. RUN_MIGRATIONS="${RUN_MIGRATIONS:-true}"
DB_URL="jdbc:postgresql://@:5432/<<database>>"
#psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
# CREATE DATABASE $DB_NAME;
#EOSQL
echo "coming..."
if [ "$RUN_MIGRATIONS" == "true" ]; then
echo "running migrations ..."
${FLYWAY_EXE} -user=<<user>> -password=<<password>> -url=$DB_URL -locations="filesystem:$MIGRATIONS_LOCATION" migrate
fi Errors ->
Any thoughts? May be this doesn't work for jdbc drivers? Is this a bug in the image? |
Beta Was this translation helpful? Give feedback.
-
Are the |
Beta Was this translation helpful? Give feedback.
-
I sanitized them. I found a work around from other posts and trying that. Will keep you posted. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a requirement to run the flyway migrations during docker run as soon as the postgres docker container is run.
So, based on my analysis on the docker-entrypoint.sh, it sounds like the file names should be in a certain order as they follow sequence to run. I created
a_initial_setup.sql
andinit_db.sh
so that I can create a database and the users and do the grants. So, the database is created correctly and the logs shows that server is running, but when I am trying to connect using localhost on port 5432 it doesn't work. I get below errors -waiting for server to start....2022-10-14 01:59:58.400 UTC [123] LOG: starting PostgreSQL 12.12 (Debian 12.12-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2022-10-14 01:59:58.403 UTC [123] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-10-14 01:59:58.492 UTC [127] LOG: database system was shut down at 2022-10-14 01:59:57 UTC
2022-10-14 01:59:58.513 UTC [123] LOG: database system is ready to accept connections
done
server started
CREATE DATABASE
/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/a_initial_setup.sql
CREATE ROLE
GRANT
CREATE SCHEMA
GRANT
CREATE EXTENSION
/usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/init_db.sh
HOSTNAME...localhost
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address
Is the server running on that host and accepting TCP/IP connections?
Sample flyway migration code -
Does the server not running on port 5432 or it runs on random port? How do I over come this error? Critical for the work I am doing now. Any thoughts are appreciated.
Beta Was this translation helpful? Give feedback.
All reactions