drizzle-team / drizzle-team/drizzle-orm

[FEATURE]: Read-only pending migrations check

Open
#6,281 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Feature hasn't been suggested before.

- [ ] I have verified this feature I'm about to request hasn't been suggested before. (It has: #2791 and discussion #5685, see Related. Left unticked on purpose.)

### Describe the enhancement you want to request

A read-only way to list pending migrations: the migrations present in the folder and absent from `drizzle.__drizzle_migrations`, without creating the table or applying anything.

Shape: an exported `getPendingMigrations({ migrationsFolder, db })` returning names, or a `dryRun: true` option on `migrate()`.

### Why

We run `migrate()` in a pre-deploy step and want the server to refuse to start while any migration is pending, so a deploy whose migrate step was skipped cannot serve on an old schema. Rails ships this as `check_all_pending!`.

Today we read the folder with `readMigrationFiles` and compare names against the table, mirroring what `getMigrationsToRun` does internally. That reimplements the migrator's selection rule and diverges silently the day the rule changes.

Matching by name rather than by a timestamp high-water mark matters, see #5769.

### Related

#2791 asks for this and has no maintainer reply since 2024. Discussion #5685 asks the same. Filed anew so it reaches the current queue, happy to have it closed into #2791 if that is where it should live.

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing readMigrationFiles and getMigrationsToRun paths, along with migrate and the drizzle.__drizzle_migrations table handling. Compare the requested API options with the prior requests in #2791 and discussion #5685; done means exposing a read-only pending-migration check that matches the migrator's name-based selection without creating tables or applying migrations.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.