Skip to content

fix(db): seed_models sync-deletes config-removed models to avoid ghost market rows (v0.7.2) - #103

Merged
argszero merged 1 commit into
mainfrom
fix/seed-models-sync
Aug 20, 2026
Merged

argszero merged 1 commit into
mainfrom
fix/seed-models-sync

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Fix the "ghost model" bug: seed_models only upserted config [[models]] into the models table and never deleted rows that were removed from config — so models dropped from config.toml stayed in the DB forever and kept showing up in the market list.

Now seed_models performs a full sync on startup: upsert every config model, then delete any models row whose (provider, model) is not in config. Config [[models]] is the authoritative single source of truth (v0.7.1 architecture).

Related Rant

  • Rant timestamp: 2026-08-20T11:58:33 — "seed_models 只 upsert 不删除,config 移除的模型永久残留 DB(市场显示幽灵模型)"

Changes

  • src/db.rs — seed_models: after upserting config models, scan DB rows and delete (provider, model) pairs absent from config (models table has no FK references; usage_records/transactions store model as string). Log counts of upserted vs deleted rows.
  • src/db.rs — new test seed_models_deletes_config_removed_rows: inserts a ghost row, re-seeds, asserts the ghost row is removed and row count returns to the config-set size.
  • src/routes/admin_models.rs — doc note: admin runtime add/edit/delete is overridden/cleared on next restart since config is authoritative (persist custom models via config.toml).
  • README.md — v0.7.2 changelog entry.
  • Cargo.toml / Cargo.lock — version bump 0.7.1 → 0.7.2.

Tests

  • cargo test — 125 passed (124 baseline + new sync-delete test)
  • cargo clippy — 0 warnings
  • cargo fmt — clean

@argszero
argszero merged commit 53bc38f into main Aug 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant