db-migrate / pg

A postgresql driver for db-migrate.
Other
67 stars 51 forks source link

ssl configs are not working #82

Closed mjsilva closed 1 year ago

mjsilva commented 1 year ago

Hi and thank you for building this library.

When running db-migrate with the following config

{
  "sql-file": true,
  "dev": {
    "driver": "pg",
    "user": {
      "ENV": "POSTGRES_USER"
    },
    "password": {
      "ENV": "POSTGRES_PASSWORD"
    },
    "host": {
      "ENV": "POSTGRES_HOST"
    },
    "database": "main",
    "port": "5432",
    "ssl": {
      "sslcert": { "ENV": "POSTGRES_CA" },
      "sslkey": { "ENV": "POSTGRES_KEY" },
      "sslmode": "disable"
    }
  }
}

we get

[ERROR] ReferenceError: fs is not defined
    at exports.connect (/usr/src/app/node_modules/db-migrate-pg/index.js:705:46)
    at connect (/usr/src/app/node_modules/db-migrate/lib/driver/index.js:93:12)
...

This is due to fs not being initialised but used here: https://github.com/db-migrate/pg/blob/master/index.js#L704

It also looks like db-migrate-pg is expecting ssl config to be file instead of variables. This is not the case on our use case as we store sslcert and sslkey in secrets as a value instead of a file.

Thanks!

wzrdtales commented 1 year ago

fixed in 1.3.2