fix(marketplace): heal missing sample data when rehydrating installed packages onto a new database#3421
Merged
Merged
Conversation
… packages onto a new database The install ledger (.objectstack/installed-packages/) is anchored to the project directory while the database can be swapped out from under it (os dev --fresh, a deleted dev.db, a --database switch). Rehydrate deliberately never re-seeds, which left a rehydrated marketplace package permanently empty on a new database: app in the switcher, tables created, zero rows — the "HotCRM installed but every KPI is 0" state. Rehydrate now replays the bundled seed datasets iff the manifest bundles them, they were never explicitly purged (new sampleDataPurged ledger marker), the runtime is single-tenant, and EVERY seeded object is empty — one surviving row anywhere leaves the database untouched, so the heal is idempotent and can never revert user edits on restart. Install now also marks withSampleData=true on an all-skipped seed run (rows already present), instead of leaving the flag false over a seeded database. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckNo hand-written docs reference the 1 changed package(s). ✅ |
This was referenced Jul 24, 2026
Merged
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.
问题
examples/app-showcase用objectstack dev --ui --seed-admin起在全新 SQLite 库上时,已安装的 marketplace 模板包(app.objectstack.hotcrm)完全没有业务种子数据:crm_opportunity/crm_account/crm_lead等全部 0 行,executive_dashboard 所有 KPI 为 0,Sales Pipeline 看板 7 列全空。根因
安装 ledger(
<cwd>/.objectstack/installed-packages/*.json)锚定在项目目录,而数据库可以在它脚下被整个换掉(os dev --fresh的临时库、删掉的dev.db、--database切换)。重启时MarketplaceInstallLocalPlugin.rehydrate()会重新注册 manifest +syncSchemas()建表,但刻意seedNow:false不重放种子(注释假设"装机时的行还在库里")。于是出现不对称:已在 worktree 复现(拷贝 ledger + 新库):安装产物本身带全 12 个数据集 162 条种子,安装当天 inline seed 正常 —— 问题只出在"换库后的 rehydrate"。
修复
rehydrate 后新增
maybeHealSampleData():当且仅当data种子数据集;sampleDataPurgedledger 标记,purge 端点落章、install/reseed 落行后清除);seed-datasets服务);才以 upsert + multiPass 重放种子。因此对重启幂等,且永远不会覆盖用户对 demo 行的编辑。
顺手修正:install 的 seed 全部
skipped(行已在库,如对着有数据的库重装)时,withSampleData现在如实置true,不再在有数据的库上留着false假装没有样例数据。验证
marketplace-install-local-heal.test.ts):空库愈合+标志翻转、任一对象有行即跳过、purge 后重启不复活(经真实端点端到端)、多租户跳过、0 行落地保持 false 并大声告警、all-skipped install 标志修正;包内 62 测试全绿。updated_at逐字节不变(幂等)。顺带发现(不在本 PR 范围)
marketplace 包种子的 lookup/master_detail 引用自装机第一天起就未解析成 id(
crm_contact.crm_account列存的是 "Acme Corporation" 字符串)——crm_contact因sharingModel: controlled_by_parent的 RLS join 悬空而对所有人(含平台管理员)整表不可见。疑似 SeedLoader 引用图只认 metadata 服务、不认 marketplace 注册进 objectql registry 的对象定义。已另立任务跟进。🤖 Generated with Claude Code