migrate function hangs without any result

I have this in my migrate.js file

// @ts-check

const { drizzle } = require("drizzle-orm/node-postgres");
const { migrate } = require("drizzle-orm/node-postgres/migrator");
const { Client } = require("pg");
require("dotenv").config();
const path = require("path");

// for query purposes
const config = {
  host: process.env.DB_HOST,
  port: parseInt(process.env.DB_PORT || ""),
  user: process.env.DB_USER,
  database: process.env.DB_NAME,
  password: process.env.DB_PASSWORD,
  connectionTimeoutMillis: 10000,
};
console.table(config);
const client = new Client(config);

console.log(path.join(process.cwd(), "drizzle"));

async function main() {
  try {
    await migrate(drizzle(client), {
      migrationsFolder: path.join(process.cwd(), "drizzle"),
    });
    console.log("success");
    client.end();
    process.exit(0);
  } catch (error) {
    console.log("error: ", error);
    client.end();
    process.exit(1);
  }
}
await main();

when I run the file with bun everything hangs and nothing get's executed, the log functions log the correct credentials and file path but the execution stops after the migrate call, it hangs longer than the timeout so I don't think it is a database issue
Was this page helpful?