db-migrate / node-db-migrate

Database migration framework for node
Other
2.32k stars 360 forks source link

db-migrate up ends after "connecting" with no error or info #709

Closed paulmiller3000 closed 4 years ago

paulmiller3000 commented 4 years ago

I'm submitting a...

Current behavior

I'm using Docker to run two containers: one for my app and one for my database. Both containers start successfully, but my migrations are not running. After opening a shell to my container, I run db-migrate up --verbose. This results in the following output:

[INFO] Detected and using the projects local version of db-migrate. '/pixapad-api/node_modules/db-migrate/index.js'
[INFO] Environment variable HEROKU_POSTGRESQL_BLACK_URL is empty!
[INFO] Using development settings: {
  driver: 'postgres',
  user: 'postgres',
  password: '******',
  host: 'pixapad-db',
  database: 'pixapad-local',
  schema: 'public',
  port: '5432'
}
[INFO] require: db-migrate-pg
[INFO] connecting

Unfortunately, it then returns to the command prompt. The migrations are not run, and no output is generated indicating why db-migrate stops after the connecting step.

I verified the host name is correct (the "_1" appended to the container name doesn't seem to matter):

$ docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS                            NAMES
2725ac3e45c4        pixapad-api_pixapad-api   "docker-entrypoint.s…"   8 seconds ago       Up 6 seconds        0.0.0.0:4000->4000/tcp           pixapad-api_pixapad-api_1
077a8de1f1a3        dpage/pgadmin4            "/entrypoint.sh"         8 seconds ago       Up 6 seconds        443/tcp, 0.0.0.0:18080->80/tcp   pixapad-api_pixapad-pgadmin_
1
1388bc27833b        postgres                  "docker-entrypoint.s…"   8 seconds ago       Up 8 seconds        0.0.0.0:5432->5432/tcp           pixapad-api_pixapad-db_1

I can ping the database container (pixapad-db) from inside the app container (pixapad-api):

$ docker exec -it pixapad-api_pixapad-api_1 bash
root@2725ac3e45c4:/pixapad-api# ping pixapad-db
PING pixapad-db (192.168.80.2) 56(84) bytes of data.
64 bytes from pixapad-api_pixapad-db_1.pixapad-api_default (192.168.80.2): icmp_seq=1 ttl=64 time=0.284 ms
64 bytes from pixapad-api_pixapad-db_1.pixapad-api_default (192.168.80.2): icmp_seq=2 ttl=64 time=0.164 ms
64 bytes from pixapad-api_pixapad-db_1.pixapad-api_default (192.168.80.2): icmp_seq=3 ttl=64 time=0.131 ms
64 bytes from pixapad-api_pixapad-db_1.pixapad-api_default (192.168.80.2): icmp_seq=4 ttl=64 time=0.140 ms
64 bytes from pixapad-api_pixapad-db_1.pixapad-api_default (192.168.80.2): icmp_seq=5 ttl=64 time=0.127 ms
64 bytes from pixapad-api_pixapad-db_1.pixapad-api_default (192.168.80.2): icmp_seq=6 ttl=64 time=0.128 ms
^C
--- pixapad-db ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5095ms
rtt min/avg/max/mdev = 0.127/0.162/0.284/0.056 ms

So the container is reachable.

Just for fun, I replaced my host name with a random string, then ran db-migrate up --verbose again. As expected, that resulted in a getaddrinfo ENOTFOUND exception. Returning to the correct host name once again resulted in no error or migration.

I'm at a loss as to why db-migrate is starting but then stops early without giving an indication as to why.

What should I check next?

Environment


db-migrate version: 0.11.11
db-migrate driver with versions: db-migrate-pg version 1.0.0

Additional information:
- Node version: 14.0
- Platform:  Linux            
paulmiller3000 commented 4 years ago

Success! Per this thread, I updated db-migrate-pg from 1.0.0 to 1.2.2. Problem solved.