I thought I'd give Drizzle a try instead of Prisma for a new use case, because it looks simpler. After following their guide, and creating this config, then running drizzle-kit push as per the guide, I get an invalid URL error because my env var isn't being read. I'm guessing this is because the Nextjs runtime isn't reading .env because this runs independenly of it. If I hard code the url here the push works fine. What can I do to somehow get the evn read?
import 'dotenv/config';
import { defineConfig } from 'drizzle-kit';
require('dotenv').config();
export default defineConfig({
out: './drizzle',
schema: './src/drizzle/schema.ts',
dialect: 'postgresql',
dbCredentials: {
url: process.env.DATABASE_URL || "",
},
});
The require is merely the last of many attempts to get the variables read, none of which worked.