Repository navigation
fix(db): seed_models sync-deletes config-removed models to avoid ghost market rows (v0.7.2) - #103
Merged
Merged
Conversation
…t market rows (v0.7.2)
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.
Summary
Fix the "ghost model" bug:
seed_modelsonly upserted config[[models]]into themodelstable and never deleted rows that were removed from config — so models dropped fromconfig.tomlstayed in the DB forever and kept showing up in the market list.Now
seed_modelsperforms a full sync on startup: upsert every config model, then delete anymodelsrow whose (provider, model) is not in config. Config[[models]]is the authoritative single source of truth (v0.7.1 architecture).Related Rant
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 testseed_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 warningscargo fmt— clean