fix(db): follow-up improvements for database configuration#7
Merged
raychrisgdp merged 2 commits intomainfrom Jan 3, 2026
Merged
fix(db): follow-up improvements for database configuration#7raychrisgdp merged 2 commits intomainfrom
raychrisgdp merged 2 commits intomainfrom
Conversation
- Add vector store directory creation in ensure_app_dirs() - Add --yes flag to tgenie db restore for automation - Enforce SQLite foreign keys at engine connection level - Update troubleshooting documentation with current DB paths
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
Issues & Goals:
data/chroma) is created alongside other app directories--yesflag totgenie db restorefor automation while maintaining safety confirmationsImplementation Highlights:
Settings.ensure_app_dirs()usingvector_store_pathproperty inbackend/config.py--yesflag totgenie db restorecommand inbackend/cli/db.pyto skip confirmation prompts for automation (consistent withdb resetpattern)backend/database.py-PRAGMA foreign_keys=ONnow executes on every new connectiontests/test_config.py), restore with--yesflag (tests/cli/test_db.py), and engine-level FK enforcement (tests/test_database.py)docs/TROUBLESHOOTING.mdto reflect current default database path (~/.taskgenie/data/taskgenie.db) and environment override behaviorHow to Test
CLI and Database Configuration Testing:
Vector Store Directory Creation:
Database Restore with Confirmation:
Database Restore on Non-Existent Database:
Engine-Level Foreign Key Enforcement:
Automated Test Execution:
# Run all related tests uv run pytest tests/test_config.py::test_app_data_dir_creation -v uv run pytest tests/test_database.py::test_engine_level_foreign_keys_enabled -v uv run pytest tests/cli/test_db.py::test_db_restore_with_yes_flag -vExpected Behavior:
~/.taskgenie/data/chroma) is created whenensure_app_dirs()is calledtgenie db restoreprompts for confirmation only when target database existstgenie db restore --yesskips confirmation prompt when database existstgenie db restoredoes not prompt when target database does not existPRAGMA foreign_keysreturning1)Related Issues
Author Checklist
mainbranchAdditional Notes
Key Implementation Areas for Review
CLI Changes:
backend/cli/db.py: Added--yesflag torestorecommand - verify confirmation logic (if not yes and db_path.exists()) correctly gates prompts and matchesdb resetpatternConfiguration Changes:
backend/config.py: Addedself.vector_store_path.mkdir()inensure_app_dirs()- verify directory creation uses canonical settings helper and doesn't create directories at import timeDatabase Changes:
backend/database.py: Added_enable_sqlite_foreign_keys()function with SQLAlchemy event listener - verifyPRAGMA foreign_keys=ONexecutes on every new connection viaevent.listens_for(engine.sync_engine, "connect")and works with async enginesinit_db()andinit_db_async()functionsTesting:
tests/test_config.py: Added assertion forvector_store_path.exists()- verify directory creation test coveragetests/test_database.py: Addedtest_engine_level_foreign_keys_enabled- verify FK enforcement test uses raw connection (bypassingget_db()session) to test engine-level behaviortests/cli/test_db.py: Addedtest_db_restore_with_yes_flag- verify restore command test covers--yesflag behaviorDocumentation:
docs/TROUBLESHOOTING.md: Updated database section - verify default path guidance (~/.taskgenie/data/taskgenie.db) and environment override mentions (TASKGENIE_DATA_DIR,DATABASE_URL) are accuratedocs/02-implementation/pr-specs/PR-017-db-config-followups.md: Spec file updated - verify implementation matches spec requirementsTesting Notes
--yesflag follows the same pattern asdb resetcommand, maintaining consistency across destructive operationsget_db()session helperensure_app_dirs()method, not at import timetgenie db restore) to test confirmation prompts and--yesflag behavior interactivelytmp_pathfixture for isolated database and directory testing