feat(data): add note metadata DataApi and cache schemas for v2 migration#13312
Open
feat(data): add note metadata DataApi and cache schemas for v2 migration#13312
Conversation
Add the data API layer for notes management: - SQLite `note` table with path-based primary key, isStarred, timestamps - CRUD API endpoints: GET/PATCH/DELETE /notes/:path, GET /notes - NoteService with upsert semantics for metadata management - PersistCache keys for notes UI state (active_file_path, expanded_paths) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…igration Reads starredPaths from Redux note slice and inserts them into the note table with isStarred=true. Registered in migration pipeline with order=5 (after chat migrator). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
Replace path-only primary key with UUID id + unique path column. Path varies across devices; id serves as stable cross-device identifier for future cloud sync scenarios. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…restore - Add relativePath column (relative to notesRoot, forward-slash normalized) - NoteService computes relativePath via path.relative() from preference - NoteMigrator reads notesPath from Redux to compute relativePath during migration - Enables Mac→Win backup-restore by matching notes via relativePath Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
path can always be computed at runtime as notesRoot + relativePath. Keeping only relativePath avoids data redundancy and makes cross-platform backup-restore work without path fixup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Generate migration 0002 to create the `note` table with UUID primary key, unique `relative_path` column, `is_starred` flag, and timestamps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: suyao <sy20010504@gmail.com>
…nd docs - Register noteTable in MigrationEngine.verifyAndClearNewTables so note table is properly cleared on re-migration - Add 12 unit tests for NoteMigrator (prepare/execute/validate phases) - Add README-NoteMigrator.md documenting data sources, field mappings, transformations, and edge cases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: suyao <sy20010504@gmail.com>
…paths NoteMigrator now recursively scans the notes directory for all .md files and creates note table entries for each, with isStarred set based on Redux starredPaths membership. Previously only starred paths from Redux were migrated, missing all non-starred note files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: suyao <sy20010504@gmail.com>
…others Revert filesystem scanning in NoteMigrator. Only migrate starred paths from Redux; non-starred note files will be lazily registered by NoteService at runtime. This keeps migration fast, avoids filesystem dependency, and uses a single registration code path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: suyao <sy20010504@gmail.com>
Non-starred note files need to be lazily registered by NoteService when the notes directory is first loaded at runtime. Added TODO comment to track this pending renderer-layer work. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: suyao <sy20010504@gmail.com>
Collaborator
|
Also #12150 |
…tion plan Add comments documenting how the note table will integrate with the file manager node table (PR #13451): add nodeId FK, backfill from relativePath, and eventually derive path from node tree. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: suyao <sy20010504@gmail.com>
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.
What this PR does
Before this PR:
Note starred paths were stored in Redux (
store/note.ts) with no database persistence. UI state like active file path and expanded paths had no v2 data layer support.After this PR:
noteSQLite table for note metadata (path, isStarred, timestamps), extensible for future fields (AI tags, etc.)GET /notes,GET/PATCH/DELETE /notes/:path) with NoteServicenotes.active_file_path,notes.expanded_paths) for UI stateWhy we need it and why it was done in this way
This is the data API layer (Phase 2) for migrating
store/note.tsto the v2 architecture. Thenotetable uses file path as primary key since notes are filesystem-based. It is designed to be extensible —isStarredis the first metadata field, with future fields (AI features, tags) planned under the same table.The following tradeoffs were made:
getByPathauto-creates metadata entries (upsert) — avoids requiring explicit creation before useThe following alternatives were considered:
note_starredtable with only path+createdAt — rejected because the notes domain will grow with more metadata fieldsBreaking changes
None.
Special notes for your reviewer
preferenceSchemas.tsandPreferencesMappings.tsin a previous commit.Checklist
Release note