drizzle-team / drizzle-team/drizzle-orm
[FEATURE]: Support for Multiple `--env-file` Flags in Drizzle Kit CLI
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Feature hasn't been suggested before.
- [x] I have verified this feature I'm about to request hasn't been suggested before.
### Describe the enhancement you want to request
**Summary:**
Currently, Drizzle Kit relies on configuration files (e.g., `drizzle-dev.config.ts`, `drizzle-prod.config.ts`) to manage different environments. While functional, this approach lacks flexibility, especially when integrating into various workflows or CI/CD pipelines. Introducing support for multiple `--env-file` flags in the Drizzle Kit CLI would streamline environment management and align with modern development practices.
**Background:**
In Node.js, it’s common to load environment variables using multiple .env files to separate base configurations from environment-specific overrides. For instance:
```sh
node --env-file=.env --env-file=.env.production your_script.js
```
This approach allows developers to maintain a default `.env` file and override specific variables in `.env.production`, `.env.ci`, etc. to switch between DB URLs.
**Proposed Enhancement:**
Enable Drizzle Kit CLI commands (e.g., migrate, generate, push) to accept one or more --env-file flags, allowing users to specify the order and combination of environment files to load. For example:
```sh
drizzle-kit migrate --env-file=.env --env-file=.env.production
```
This command would first load variables from .env, then override them with any variables defined in .env.production.
**Benefits:**
1. **Enhanced Flexibility**: Developers can manage environment variables more dynamically without creating multiple configuration files.
2. **Simplified Workflows**: Reduces the need for multiple drizzle.config.ts files, streamlining project structure.
3. **Improved CI/CD Integration**: Facilitates easier environment management in automated pipelines by specifying environment files directly in scripts.
4. **Alignment with Node.js Practices**: Mirrors the behavior of Node.js’s native --env-file support, providing a consistent developer experience.
**Use Case Example:**
In package.json, one could define scripts as follows:
```json
{
"scripts": {
"db:migrate:prod": "drizzle-kit migrate --env-file=.env --env-file=.env.production"
}
}
```
This setup allows for clear and concise environment management within npm scripts.
Contributor guide
Assessment
This issue has not been assessed yet.