fix(backend): migrate folders tables that predate indexing_status - #1579
harshvardhanrp wants to merge 1 commit into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: AOSSIE-Org/PictoPy/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. WalkthroughDatabase initialization now migrates legacy ChangesFolder indexing status
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~12 minutes Change: Bug fix Suggested labels: Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change repairs legacy folder databases while preserving existing indexing statuses and defaults for new folders. No actionable merge-blocking risk remains in the supplied evidence; merge after normal checks pass. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The upgrade restores compatibility for older folder databases without an identified expansion of access or privileges. However, an interrupted upgrade can leave existing folders marked as pending, and restarting does not reliably repair that state. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit checks the folders one by one, Comment |
Link your account with GitcordThanks for opening this PR, @harshvardhanrp! To receive Discord notifications and contributor tracking for this organization:
Once linked, Gitcord can notify you about reviews, merges, and more. — Posted by Gitcord |
Partially addresses #1555
That issue reports the symptom correctly, the folder list 500s with "no such column: f.indexing_status" after an upgrade. The cause it gives is not right though. There is no
migration_009_add_indexing_status.pyand no migration runner in this repo. Tables are created and patched idempotently at startup inmain.py.The real cause is that
folders.indexing_statuswas added to the CREATE TABLE in #1380 with no guarded ALTER. CREATE TABLE IF NOT EXISTS skips a table that already exists, so a database from 1.2.0 or older keeps the old six column table while every query asks for the seventh.GET /folders/all-foldersreturns 500 anddb_is_indexing_busyraises, which breaks/memories/statustoo. Every release before #1380 is affected, so 1.2.0, 1.1.0, 1.0.0 and 0.1.1.Added the guarded ALTER the other tables already use, with the same default as the CREATE so a migrated schema matches a fresh one. Existing folders are backfilled to
completedbecause the old version really did index them, andisIndexingPendingtreats anything other than completed or interrupted as pending. Leaving them on the default would put a spinner on every folder and keep the one second poll running forever.Checked by building a 1.2.0 database with the 1.2.0 release code, then running the current startup order and calling the real route. Before the change it is HTTP 500, after it is HTTP 200 with indexing_status completed. Four new tests in
test_folders.pyfail before and pass after. Full suite is 1352 passing with black, ruff and mypy clean.Also fixed two pre existing mypy errors that CI only flags because this PR touches these files. A list concat in
db_update_ai_tagging_batchand four untyped dicts in the tests. Happy to split those into their own PR.Not covered here are the three frontend items in #1555, the generic error dialog, the one second dialog spam and the missing
refetchOnWindowFocus. Those sit on top of this backend fix and can be a follow up.Summary by CodeRabbit