Skip to content

feat(db): Upgrade drizzle-orm and drizzle-kit to 1.0.0-rc.6 - #4242

Merged
BYK merged 1 commit into
mainfrom
byk/drizzle-v1
Nov 24, 2026
Merged

BYK merged 1 commit into
mainfrom
byk/drizzle-v1

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Upgrades drizzle-orm and drizzle-kit to 1.0.0-rc.6, the newest 1.0 pre-release, pinned in the catalog. Migrations use the v1 folder layout, so two PRs that add migrations no longer conflict in a journal. drizzle-kit check reports only real collisions.

Existing databases

applyMigrations now writes the v1 migration table (hash, created_at, name, applied_at) and picks pending migrations by folder name, as the v1 migrator does. A table from 0.x has only hash and created_at. On the first run, one transaction adds the two columns and names each row:

  • A row matches the migration with the same time, else the same SQL hash, else the same second. v1 reads the time from the folder name with second precision, and the converted SQL is byte for byte the old SQL.
  • The earlier plugin adoption recorded only its newest migration. The migrations before it get rows too, so every applied migration has a named row.

After that, the only pending migration is the new no-op baseline, and Drizzle's own migrator sees the same table. A 0.x-shaped core table with all 174 rows went through this: 174 existing, 1 migrated (the baseline), no unnamed rows. Then stock migrate() from drizzle-orm/node-postgres/migrator found nothing to run.

Changes

  • drizzle-kit up converted all migrations in the three packages (174 core, 22 GitHub, 1 Google).
  • Two explicit FK names now use the 63-character prefix that Postgres already stores, so the database does not change.
  • 20261124202143_drizzle_v1_baseline holds only comments. Its snapshot records the v1 form of 40 index and 35 check expressions, so generate does not rebuild them ([BUG]: Postgres: drizzle-kit up (v7 → v9) leaves table-qualified index/check expressions and unnormalized custom types, so the first generate on 1.0.0-rc.5 rebuilds every partial index and check constraint drizzle-team/drizzle-orm#6589). The GitHub and Google packages need no baseline: drizzle-kit check reports no schema change for all three.
  • drizzle() no longer gets schema, since v1's relational queries need relations instead. The database types are now PgAsyncDatabase<PgQueryResultHKT>. The one RQBv1 call, in the eval recording export, uses readConversationEventRows.
  • Removed strict from the drizzle configs. v1 dropped the option, and push now asks before data loss by default.
  • Updated the migration checks:
    • migration-metadata:check checks the folder layout and runs drizzle-kit check, which fails on conflicting migrations or a schema that no migration creates.
    • money-units:check and provider-state:check rebuild the schema from the delta snapshots with drizzle-kit's reconstruct().
    • migration-locks:check, its baseline (same entries) and .squawk.toml read <folder>/migration.sql.
  • Removed pnpm db:rebase from feat(migrations): Regenerate branch migrations with pnpm db:rebase #4121. Folder names order the migrations, and a migration that merges after a newer one still runs, so the journal when rule has nothing left to protect.
  • The test global setup and the GitHub skip list use folder names.

via @BYK.

--

View Session [Sentry]

Move all migrations to the Drizzle v1 folder layout with drizzle-kit up,
record migration names the way the v1 migrator does, and switch the
migration checks to the folder layout. drizzle-kit check now reports
conflicting migrations from parallel branches, so the journal rebase
script is no longer needed.

Co-Authored-By: BYK <[email protected]>
@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 24, 2026 9:02pm UTC

Request Review

@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 24, 2026 21:15
@sentry-junior
sentry-junior Bot requested a review from BYK November 24, 2026 21:15
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 24, 2026

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to get most of the benefits like deleting the old snapshot.json files before upgrading Drizzle? Also what are the changes in it? Is it all safe to upgrade?

@sentry-junior

sentry-junior Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@BYK Answers to your three questions:

Can we get the benefits on 0.x first?

Mostly no. The parts that work on 0.x already merged in #4129: the migrator runs every migration that has no row, so a migration that merges after a newer one still runs.

What's left needs v1:

  • Removing the journal conflicts. drizzle-kit 0.31 needs meta/_journal.json. generate and check read it, and so does readMigrationFiles in drizzle-orm 0.x. The folder layout only works with v1.
  • Deleting the old snapshots first breaks the upgrade. On 0.x, generate reads only the newest snapshot, so the old meta/NNNN_snapshot.json files could go. But v1's drizzle-kit up reads the snapshot of every journal entry and stops with MigrationSnapshotNotFoundCliError when one is missing (planFoldersV3 in drizzle-kit rc.6). Without those files we would have to write the folders by hand.

The upgrade removes the size anyway. v1 snapshots are diffs. Only the first one is a full base snapshot, and each later one holds only the change of its migration. Total snapshot size:

Package 0.x v1
core 21.8 MB (174 files) 0.8 MB
junior-github 209 KB 58 KB

That's most of the -757k lines under migrations/ in this PR. In v1 every snapshot.json must stay: reconstruct() walks the diffs back to the base snapshot.

What changes

  • Migration files. drizzle-kit up converted all migrations (174 core, 22 GitHub, 1 Google). Each migration.sql is byte for byte the old SQL, and the folder names keep the journal times, to the second.
  • The database. The schema doesn't change:
  • The migration table. On the first deploy, one transaction adds the name and applied_at columns and names each existing row. It matches each row by exact time, then by hash, then by same second. It also adds rows for plugin migrations that the old adoption skipped.
  • Runtime code. drizzle() no longer gets schema. The DB types change to PgAsyncDatabase<PgQueryResultHKT>. The only RQBv1 call, in the eval recording export, now uses a plain select. Query-builder calls don't change.
  • Tooling. The check scripts, .squawk.toml, the locks baseline, test global setup, and fixtures use the folder layout. pnpm db:rebase is gone.

Is it safe?

For the database, I think yes:

  • Tested upgrade. I ran it locally on a 0.x-shaped core migration table with all 174 rows. The run found 174 existing, applied 1 (the no-op baseline), and left no unnamed rows. Stock migrate() from drizzle-orm v1 then found nothing to run.
  • Rollback. Rolling back to the 0.x code should be safe too. I checked this by reading the code, not by running it. The 0.x migrator reads only hash and created_at and matches by time, then by hash. The upgrade doesn't change those values, and 0.x ignores the baseline row.

The real risks:

  • 1.0.0-rc.6 is a release candidate, not stable 1.0. It's pinned exactly in the catalog.
  • New migrations need v1's drizzle-kit generate. Open PRs that add 0.x-style migrations must rebase and run drizzle-kit up, or regenerate.
  • The one red check, the integration evals history.eval.ts > matches the rows of a real web turn, isn't from this PR. It fails the same way on unrelated 0.x branches, for example run 45483170217.

@sentry-junior
sentry-junior Bot requested a review from BYK November 24, 2026 21:59
@BYK
BYK merged commit 3c60b5a into main Nov 24, 2026
68 of 70 checks passed
@BYK
BYK deleted the byk/drizzle-v1 branch November 24, 2026 22:03
BYK added a commit that referenced this pull request Nov 25, 2026
…4326)

The Drizzle v1 upgrade (#4242) moved each migration into
its own folder,
`migrations/<timestamp>_<name>/{migration.sql,snapshot.json}`, and
removed `migrations/meta/`. The `linguist-generated` pattern still
pointed at `migrations/meta/**`, so it matched nothing, and new
snapshots showed up in full in PR diffs again.

This points the pattern at `packages/*/migrations/*/snapshot.json`.
`migration.sql` still shows in full.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3A99464d99add86b2407340a49 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/local%3Aweb%3A99464d99add86b2407340a49)
[[Sentry]](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A99464d99add86b2407340a49/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 1bce36c4 Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant