fix(db): correct migration when-timestamp ordering (0009/0010 skipped) - #36
Merged
Merged
Conversation
Hand-written 0007/0008 had future-dated journal `when` values (~2026-07-14); 0009 (collections) and 0010 (data_sources), generated 2026-07-13 with real lower timestamps, sorted before them and were silently skipped by drizzle-kit migrate once 0008 was applied — so fresh installs created neither table and the dev DB was missing data_sources (Data Sources page 500'd). Bumped 0009→1784000200000, 0010→1784000300000 so all `when`s are monotonic by idx. Verified a from-scratch migrate now creates collections + data_sources. DECISIONS D-179. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F1ad6jb5mCYxzFVXHbksqi
There was a problem hiding this comment.
Pull request overview
This PR fixes Drizzle migration application order by correcting the when timestamps in the Drizzle migrations journal so migrations 0009 (collections) and 0010 (data_sources) are no longer skipped after applying 0008. This addresses fresh-install and dev DB failures where the collections and/or data_sources tables were missing due to non-monotonic journal timestamps.
Changes:
- Updated
meta/_journal.jsonto bump migration0009and0010whenvalues so they are monotonic withidxand greater than0008. - Added Decision D-179 documenting the root cause, impact, and the fix rationale.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/server/src/db/migrations/meta/_journal.json | Adjusts Drizzle journal when timestamps for migrations 0009/0010 to ensure they are applied after 0008 rather than skipped. |
| docs/progress/DECISIONS.md | Documents the migration-ordering incident and resolution as Decision D-179 for future reference. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hand-written migrations 0007/0008 had future-dated journal
whenvalues (~2026-07-14); 0009 (collections) and 0010 (data_sources), generated 2026-07-13 with real lower timestamps, sorted before them and were silently skipped by drizzle-kit migrate once 0008 was applied. Effect: fresh installs created neithercollectionsnordata_sources, and the dev DB was missingdata_sources(the Data Sources page returned 500 on "relation does not exist").Fix: bumped 0009 and 0010 journal
whenvalues above 0008 so all timestamps are monotonic by idx. Verified: a from-scratchdrizzle-kit migratenow creates both tables. See DECISIONS D-179.No schema/SQL change — journal metadata only.
🤖 Generated with Claude Code
https://claude.ai/code/session_01F1ad6jb5mCYxzFVXHbksqi