👷 build(database): improve user memory schema#9822
Conversation
|
@nekomeowww is attempting to deploy a commit to the LobeHub Community Team on Vercel. A member of the Team first needs to authorize it. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR refactors the user memories schema by introducing JSONB label fields, adding an episodic date to identities, removing obsolete context and focus columns, and synchronizing migrations and documentation. Entity Relationship diagram for updated user memories schemaerDiagram
USERS ||--o{ USER_MEMORIES : "has"
USER_MEMORIES ||--o{ USER_MEMORIES_IDENTITIES : "has"
USER_MEMORIES ||--o{ USER_MEMORIES_PREFERENCES : "has"
USER_MEMORIES {
text userId
jsonb labels
jsonb extractedLabels
varchar255 memoryCategory
varchar255 memoryLayer
varchar255 memoryType
}
USER_MEMORIES_IDENTITIES {
varchar255 id
text userMemoryId
jsonb labels
jsonb extractedLabels
varchar255 type
text description
vector descriptionVector
timestamptz episodicDate
text relationship
text role
}
USER_MEMORIES_PREFERENCES {
varchar255 id
text userMemoryId
}
Class diagram for updated user memories schema typesclassDiagram
class UserMemories {
+text userId
+jsonb labels
+jsonb extractedLabels
+varchar255 memoryCategory
+varchar255 memoryLayer
+varchar255 memoryType
// ...
}
class UserMemoriesIdentities {
+varchar255 id
+text userMemoryId
+jsonb labels
+jsonb extractedLabels
+varchar255 type
+text description
+vector descriptionVector
+timestamptz episodicDate
+text relationship
+text role
// ...
}
class UserMemoriesPreferences {
+varchar255 id
+text userMemoryId
// ...
}
UserMemories "1" --o "*" UserMemoriesIdentities : has
UserMemories "1" --o "*" UserMemoriesPreferences : has
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
TestGru AssignmentSummary
Tip You can |
|
Thank you for raising your pull request and contributing to our Community |
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `packages/database/src/schemas/userMemories.ts:16-19` </location>
<code_context>
userId: text('user_id').references(() => users.id, { onDelete: 'cascade' }),
+ labels: jsonb('labels'),
+ extractedLabels: jsonb('extracted_labels'),
+
memoryCategory: varchar255('memory_category'),
</code_context>
<issue_to_address>
**suggestion:** Consider clarifying the distinction between 'labels' and 'extractedLabels'.
Since both columns store label data, please clarify their distinct roles in code and documentation to prevent confusion and potential data integrity issues.
```suggestion
/**
* 'labels' stores user-assigned labels for the memory.
* These are manually added or edited by the user to categorize or tag the memory.
*/
labels: jsonb('labels'),
/**
* 'extractedLabels' stores labels automatically extracted from the memory content.
* These are generated by the system (e.g., via NLP or ML) and may differ from user-assigned labels.
*/
extractedLabels: jsonb('extracted_labels'),
```
</issue_to_address>
### Comment 2
<location> `packages/database/migrations/0039_goofy_unicorn.sql:1` </location>
<code_context>
+ALTER TABLE "user_memories_preferences" DROP CONSTRAINT "user_memories_preferences_context_id_user_memories_contexts_id_fk";
+--> statement-breakpoint
+ALTER TABLE "user_memories" ADD COLUMN "labels" jsonb;--> statement-breakpoint
</code_context>
<issue_to_address>
**issue (bug_risk):** Dropping foreign key constraints can lead to orphaned records.
If this change is intentional, please ensure there are mechanisms in place to prevent or clean up orphaned 'user_memories_preferences' records.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9822 +/- ##
=========================================
Coverage 84.51% 84.51%
=========================================
Files 945 945
Lines 64967 64967
Branches 7974 9673 +1699
=========================================
Hits 54905 54905
Misses 10062 10062
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
arvinxx
left a comment
There was a problem hiding this comment.
另外得 rebase 下 main,知识库那边有个 PR 先合了
|
❤️ Great PR @nekomeowww ❤️ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
|
🎉 This PR is included in version 1.142.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
chore(database): improve user memory schema
…pdate signing (#15527) electron-builder was floating on `^26.8.1` and the repo commits no lockfile, so each CI build resolved a fresh version. The canary.12 build (2026-06-07) picked up 26.15.0, which regressed macOS .app bundle signing: codesign reports "bundle format is ambiguous (could be app or framework)" and Squirrel.Mac rejects the update during code-signature validation, so the app never quits to install — surfacing as "auto-update does nothing". 26.15.0 introduced the two suspect changes (mac signing rework #9822 and the full app-builder-bin Go→TS replacement #9829). 26.14.0 predates both and does not touch macOS app-bundle signing/layout. Pinning the exact version cascades to app-builder-lib / dmg-builder / builder-util (electron-builder pins those exactly), stopping the toolchain from floating across CI installs. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
💻 Change Type
🔀 Description of Change
user_memories_identity.labelsandextracted_labelsfor baseuser_memories.context_id,experience, andcurrent_focuseswasn't needed.📝 Additional Information
Summary by Sourcery
Refactor the database schema for user memories by introducing new metadata fields and removing obsolete columns and constraints.
Enhancements: