drizzle-team / drizzle-team/drizzle-orm
[BUG]: drizzle-kit does not allow loading of .env.{development,test}{,.local}
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
0.39.2
### What version of `drizzle-kit` are you using?
0.30.4
### Other packages
_No response_
### Describe the Bug
To reproduce and verify this:
- Generate NextJS (or any other meta-framework) project from the template
- Add drizzle and it's driver dependencies - including '@next/env' or it's equivalent in other frameworks
- Configure the `drizzle.config.{ts,js}` to be similar to:
```ts
import { loadEnvConfig } from '@next/env';
import { defineConfig } from 'drizzle-kit';
const projectDir = process.cwd();
console.log(loadEnvConfig(projectDir).loadedEnvFiles);
export default defineConfig({
dialect: 'postgresql',
schema: './src/lib/supabase/schema.ts',
out: './migrations',
dbCredentials: {
host: process.env.DB_HOST!,
database: process.env.DB_NAME!,
port: process.env.DB_PORT!,
user: process.env.DB_USER!,
password: process.env.DB_PASSWORD!,
ssl: false,
}
});
```
- Run `npx drizzle-kit push`
- It will print something similar to:
```console
$ npx drizzle-kit --config ./drizzle.config.ts push
Reading config file ''
[
{ path: '.env.production.local', contents: '', env: {} },
{ path: '.env.local', contents: '', env: {} },
{ path: '.env.production', contents: '', env: {} },
{ path: '.env', contents: '', env: {} }
]
Error Either connection "url" or "host", "database" are required for PostgreSQL database connection
```
drizzle-kit does not load:
- `.env.development`
- `.env.test`
- `.env.development.local`
- `.env.test.local`
However, drizzle-kit loads:
- `.env`
- `.env.local`
- `.env.production`
- `.env.production.local`
No amount of adding `NODE_ENV=development` or `NODE_ENV=test` would over-ride this.
Contributor guide
Assessment
This issue has not been assessed yet.