environment variables undefined in drizzle.config.ts

I have my config set up like this:
import { type Config } from "drizzle-kit";

if (!process.env.DATABASE_URL) {
  throw new Error("DATABASE_URL is not set!");
}

export default {
  schema: "src/server/db/schema.ts",
  driver: "pg",
  out: "drizzle/migrations",
  dbCredentials: {
    connectionString: process.env.DATABASE_URL,
  },
} satisfies Config;


But when I try to run
db:generate
from my scripts, it throws my error designed to catch when
process.env.DATABASE_URL
is undefined. I can't figure out why it's coming up as undefined here though since it definitely does have a value, it even works when running migrations and such.

I used create-t3-app for this project btw
Was this page helpful?