I have a workspace where I want to use the npm package node-pg-migrations to handle database migrations for all of my databases.
.env file variables:
MULLIGAN_DB_USER=my_user
MULLIGAN_DB_PASSWORD=my_password
MULLIGAN_DB_HOST=localhost
MULLIGAN_DB_PORT=6969
MULLIGAN_DB_NAME=mulligan
workspace folder structure:
.
├── index.js
├── package.json
└── projects
└── mulligan
├── config.js
├── index.js
└── migrations
└── 001_initial-migration.js
The index.js file in my root is empty.
My command mulligan-migration runs the command:
node-pg-migrate $@ -c ./projects/mulligan/index.js -m ./projects/mulligan/migrations
When I run the command pnpm run mulligan-migration -- up I get the following errormessage:
pnpm run mulligan-migration -- up
> [email protected] mulligan-migration /home/mads/workspace/db-migrations
> node-pg-migrate $@ -c ./projects/mulligan/config.js -m ./projects/mulligan/migrations "--" "up"
could not connect to postgres: Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string
When console logging the config from my config.js file inside ./projects/mulligan/index.js
import { config as dotenvConfig } from "dotenv";
dotenvConfig();
import pkg from "pg";
const { Client } = pkg;
import config from "./config.js";
console.log("config", config);
const client = new Client(config);
The output is just undefined across the board from my ./projects/mulligan/config.js file.
const config = {
user: process.env.MULLIGAN_DB_USER,
password: process.env.MULLIGAN_DB_PASSWORD,
host: process.env.MULLIGAN_DB_HOST,
port: process.env.MULLIGAN_DB_PORT,
database: process.env.MULLIGAN_DB_NAME,
};
export default config;
Am I over complicating this setup? Is it even possible to do this? It would be nice to have a project that contained all of my migration logic for all other projects.
project dependencies:
"dotenv": "^16.4.5",
"node-pg-migrate": "^6.2.2",
"pg": "^8.11.3"