graphile / migrate

Opinionated SQL-powered productive roll-forward migration tool for PostgreSQL.
MIT License
751 stars 57 forks source link

Error executing commit #186

Open SPAHI4 opened 1 year ago

SPAHI4 commented 1 year ago

Summary

I got this error:

Error: getaddrinfo ENOTFOUND base
    at /Users/anton/WebstormProjects/photo-site/node_modules/.pnpm/pg-pool@3.6.1_pg@8.11.1/node_modules/pg-pool/index.js:45:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.withClient (/Users/anton/WebstormProjects/photo-site/node_modules/.pnpm/graphile-migrate@1.4.1/node_modules/graphile-migrate/dist/pgReal.js:73:26)
    at async Object._reset (/Users/anton/WebstormProjects/photo-site/node_modules/.pnpm/graphile-migrate@1.4.1/node_modules/graphile-migrate/dist/commands/reset.js:16:5)
    at async _commit (/Users/anton/WebstormProjects/photo-site/node_modules/.pnpm/graphile-migrate@1.4.1/node_modules/graphile-migrate/dist/commands/commit.js:56:5)
    at async handler (/Users/anton/WebstormProjects/photo-site/node_modules/.pnpm/graphile-migrate@1.4.1/node_modules/graphile-migrate/dist/commands/commit.js:97:9)
    at async Object.newHandler [as handler] (/Users/anton/WebstormProjects/photo-site/node_modules/.pnpm/graphile-migrate@1.4.1/node_modules/graphile-migrate/dist/cli.js:22:20) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'base'
}

watch works just fine

pnpm exec graphile-migrate watch --once
graphile-migrate: Up to date — no committed migrations to run
[2023-06-26T16:11:14.212Z]: Running current.sql
[2023-06-26T16:11:14.219Z]: current.sql unchanged, skipping migration
[2023-06-26T16:11:14.221Z]: Finished (7ms)

I'm running pnpm

 "graphile-migrate": "^1.4.1"

posgres is running with docker:

  db:
    image: postgres:15.3-alpine
    restart: always
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: app
    ports:
      - 5500:5432

config:

  "connectionString": "postgres://postgres:postgres@localhost:5500/app",
  "shadowConnectionString": "postgres://postgres:postgres@localhost:5500/app_shadow",

nodejs: 20.3.1, 18.16.1

SPAHI4 commented 1 year ago

OK I found that it is a result of missing ROOT_DATABASE_URL and it becomes template1 by default I think it needs some kind of warning because no information is confusing.

nubunto commented 1 year ago

I have ROOT_DATABASE_URL set and still having the same problem.

benjie commented 1 year ago

Most likely you are facing a configuration or environmental variable issue @nubunto.

mvnetbiz commented 1 year ago

I also have ROOT_DATABASE_URL set, but I get this error while executing the afterReset hook

Error: connect ECONNREFUSED ::1:5432

My ROOT_DATABASE_URL is for a Unix-domain socket. I can run psql "$ROOT_DATABASE_URL" or other migrate commands successfully.

mvnetbiz commented 1 year ago

My issue might be different than nubunto's. I fixed it by using the "socket:" url scheme from https://www.npmjs.com/package/pg-connection-string. It appears not all libpq compatible connection strings are supported.