From 2b9208eae4a3b032943e848fb2b2f3b520330548 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 7 Jul 2024 12:27:24 -0300 Subject: [PATCH 1/2] fix: ensure env vars are set before migrating --- bin/node-pg-migrate.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/node-pg-migrate.ts b/bin/node-pg-migrate.ts index 5983165e..015e4685 100755 --- a/bin/node-pg-migrate.ts +++ b/bin/node-pg-migrate.ts @@ -490,9 +490,12 @@ if (action === 'create') { if (!DB_CONNECTION) { const cp = new ConnectionParameters(); - if (!cp.host && !cp.port && !cp.database) { + if ( + !process.env[argv[databaseUrlVarArg]] && + (!process.env.PGHOST || !cp.user || !cp.database) + ) { console.error( - `The $${argv[databaseUrlVarArg]} environment variable is not set.` + `The ${argv[databaseUrlVarArg]} environment variable is not set or incomplete connection parameters are provided.` ); process.exit(1); } From 7f694128dbd6598ed3366a4dac7a7c5be79c28b8 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 7 Jul 2024 13:17:57 -0300 Subject: [PATCH 2/2] ci(test): add PGHOST to integration test --- .github/workflows/postgres-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/postgres-test.yml b/.github/workflows/postgres-test.yml index 2e9e86de..cb119e14 100644 --- a/.github/workflows/postgres-test.yml +++ b/.github/workflows/postgres-test.yml @@ -465,6 +465,7 @@ jobs: - name: Integration Test run: pnpm run migrate up -m test/migrations && pnpm run migrate down 0 -m test/migrations --timestamps env: + PGHOST: localhost PGUSER: ubuntu PGPASSWORD: 123456abcdefghABCDEFGH~\`\!@#$%^\&*-_=+{}[]\(\)\<\>,.\;:\"\'?\|/\\ PGDATABASE: integration_test