problems with config file dialect for PostgreSQL
versions:
drizzle-orm: 0.32.2
drizzle-kit: 0.23.2
I have something like this for my config file:
and when I try to use this config file, say for the introspect command of drizzle-kit, I get an error that says this:
which is clearly available in my config file. However, if I change the dbCredential to use a URL string with a template string to use my environment variables, it works just fine. So what's the issue here?
side note
I execute drizzle-kit using
pnpm exec
since I use pnpm on this project.11 Replies
Hello,
Not sure it
s going to help...
I had this error when i changed my .env file name to .env.local.
I
m not sure how you can fix the path, but i belive that the credentials are not beeing accessed.
In my case i was just testing something related to authentication, so i went back to the original file name and it worked.you can't destructure process.env (in nextjs)*
I’m using sveltekit
You’d think so, but if I use the url key for the dbCredential and make the url string using template strings to leverage the environment variables it works just fine.
I even made sure by putting a console log in the config file so whenever I run a command it would spit out the variables used and they all seem correct
Out of interest what do you get if you write PGUSER as string and not String(PGUSER)
Then the Config type shows me an error since PGUSER would be string | null
Write PGUSER!
I don’t have access to the code rn since it’s on my work laptop that I left in my office, but I don’t see how that would help since it’ll be a similar result to my current set up, no?
I’d give it a try on monday and keep y’all updated. If y’all have any other ideas I can try, let me know!
well last option is switch to
defineConfig not config
cool, thanks for the advice, will give that a try later
Still not fixed for me and getting same error
"drizzle-orm": "^0.33.0",
"drizzle-kit": "^0.24.0",
import { defineConfig } from 'drizzle-kit';
export default defineConfig({
schema: './src/db/schema/*',
out: './drizzle',
verbose: true,
strict: true,
introspect: {
casing: 'preserve',
},
dialect: 'postgresql',
dbCredentials: {
user: 'postgres',
password: 'root',
host: '127.0.0.1',
port: 5432,
database: 'property',
},
});
My schemas folder is empty but even changing it to schema.ts (which is an empty file) doesn't fix the errorcan you post teh error