drizzle-team / drizzle-team/drizzle-orm

[FEATURE]: Allow hooking into generating migrations

Open
#5,662 0 comments 1 reaction 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

In my app I'm using sqlite and want to add audit tables for tracking changes and fill them with triggers. I would love for a way to generate those trigger statements to keep the columns automatically in sync while the database schema evolves, i.e. generating the list of columns that should be copied into the audit tables.

For this use case it would be enough to be able to pass a function in `drizzle.config.ts` with parameters about the diff of the schema versions. The function would return a list of statements that would then be appended to the generated migration sql (separated by `--> statement-breakpoint` if configured).

Contributor guide

Open the contributing guide

Research direction

Start with drizzle.config.ts and trace the migration-generation path that produces the generated migration SQL. Determine how schema-version diffs and the configured statement-breakpoint separator are represented. Done means a configured function can receive the diff and return statements appended to the generated migration SQL.

Written by the indexing model from the issue text.

Assessment

Tech stack
sqlite, typescript
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.