docs(d1): add ORM migration workflow and Drizzle integration warnings#31813
docs(d1): add ORM migration workflow and Drizzle integration warnings#31813ivoryibu wants to merge 2 commits into
Conversation
Review
Code ReviewThis code review is in beta and may not always be helpful — use your judgment. Warnings (1)
ConventionsChecks PR title, description, and redirect checklist. No convention issues found. Style Guide ReviewWarnings (1)
Suggestions (2)
RedirectsNo missing redirect entries found. CommandsOnly codeowners can run commands. Post a comment with the command to trigger it.
|
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
|
Review of PR #31813 SummaryThis PR adds practical, technically accurate documentation for using ORMs (specifically Drizzle) with D1 migrations. It correctly warns readers about two serious gotchas — that Drizzle cannot apply migrations directly to D1, and that Suggested labels Issues requiring maintainer attention1. Style guide violation: gerund phrase in heading ( 2. Style guide suggestion: heading phrasing ( 3. Style guide issue: config key not monospace ( To prevent this, add `tablesFilter`: `["!d1_migrations", "!_cf_KV", "!sqlite_sequence"]` to your `drizzle.config.ts`.4. Style guide issue: run-on sentence (
This exceeds the recommended sentence length significantly. Break it into shorter sentences or a short list so each idea stands alone. 5. Accuracy note: hardcoded Minor notes
Overall assessmentApprove with minor revisions. The factual content is strong, the warnings address a genuine user pain point, and the structure makes sense. Fixing the heading gerund, adding backticks around |
…space tool names, tablesFilter backticks, migrations_table note
Summary
Documents the workflow for using ORMs (specifically Drizzle) with D1 migrations, and adds warnings about known gotchas that can cause data loss.
Problem
The D1 docs list Drizzle as a community project and mention its nested migration layout, but do not document:
drizzle-kit migratedoes not work with D1 (you must use Wrangler to apply)drizzle-kit generatewill generateDROP TABLEstatements for tables not in your schema file — including Wrangler's ownd1_migrationstracking table — which can cause data loss if applied blindlytablesFilterconfig option that prevents thisChanges
src/content/docs/d1/reference/migrations.mdxsrc/content/docs/d1/reference/community-projects.mdxContext
Discovered during hands-on testing of D1 schema management. When using
drizzle-kit generateagainst a D1 database, the generated migration attempted to drop thed1_migrationstable and recreate the application table from scratch (instead of usingALTER TABLE ADD COLUMN). Both behaviors are dangerous if not caught during review.