drizzle-team / drizzle-team/drizzle-orm

[FEATURE]: Add CLI flag to auto-approve drizzle-kit push prompts for CI/CD automation

Open
#4,921 5 comments 14 reactions 0 assignees View on GitHub
enhancement
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

## Problem

Currently, `drizzle-kit push --force` and the `pushSchema` API still prompt for user confirmation when adding constraints or when operations might require table truncation. This makes it impossible to use these commands in CI/CD pipelines and automated workflows where no human intervention is available.

**Related Issues:**
- #4490: `--force` does not always skip prompts
- #4531: `drizzle-kit push --force / pushSchema require manual input when adding unique constraints`

## Current Behavior

When running `drizzle-kit push --force`, users still see prompts like:

```
· You're about to add provider_key_projectId_provider_unique unique constraint to the table, which contains 2 items. If this statement fails, you will receive an error from the database. Do you want to truncate provider_key table?

❯ No, add the constraint without truncating the table
Yes, truncate the table
```

This completely breaks automation workflows and defeats the purpose of having a `--force` flag.

## Proposed Solution

Add a new CLI flag (e.g., `--auto-approve` or `--yes`) that automatically selects a default response to all prompts, eliminating the need for human interaction.

### Suggested Implementation Options:

1. **Conservative approach** (recommended): `--auto-approve=no`
- Always selects "No, add the constraint without truncating the table"
- Safe for production environments
- Allows constraints to be added without data loss

2. **Aggressive approach**: `--auto-approve=yes`
- Always selects "Yes, truncate the table"
- More dangerous but useful for development/testing environments

3. **Boolean flag**: `--auto-approve`
- Defaults to the safer "No" option
- Could be combined with another flag like `--truncate` for the aggressive approach

### Example Usage:

```bash
# Conservative - never truncate, try to add constraints safely
drizzle-kit push --force --auto-approve=no

# Aggressive - truncate when needed (for dev/test environments)
drizzle-kit push --force --auto-approve=yes

# Simple boolean version (defaults to safe behavior)
drizzle-kit push --force --auto-approve
```

## Benefits

1. **CI/CD Integration**: Enables fully automated database schema updates in deployment pipelines
2. **Developer Experience**: Eliminates manual intervention in development workflows
3. **Backward Compatibility**: Existing behavior remains unchanged without the new flag
4. **Safety**: Conservative default behavior protects against accidental data loss
5. **Flexibility**: Developers can choose the appropriate level of automation for their environment

## Use Cases

- **GitHub Actions/CI pipelines**: Deploy schema changes automatically
- **Development environments**: Rapid iteration without manual confirmations
- **Testing environments**: Automated test setup and teardown
- **Docker containerized deployments**: No terminal interaction available

## Implementation Notes

This feature should also extend to the `pushSchema` API to maintain consistency between CLI and programmatic usage.

The implementation should respect the existing `--force` flag behavior while adding this new level of automation on top of it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.