Skip to content

Fix default database path for custom user directory#14539

Open
Constantine1916 wants to merge 1 commit into
Comfy-Org:masterfrom
Constantine1916:fix/database-user-directory
Open

Fix default database path for custom user directory#14539
Constantine1916 wants to merge 1 commit into
Comfy-Org:masterfrom
Constantine1916:fix/database-user-directory

Conversation

@Constantine1916

Copy link
Copy Markdown

Fixes #14524

Summary

  • Resolve the default SQLite database URL from the effective user directory instead of the install directory.
  • Preserve explicit --database-url behavior and keep comfy.cli_args.args.database_url populated for compatibility.
  • Copy the legacy default database into the effective user directory when the target database does not exist, leaving the legacy file untouched.

Notes

For users who did not explicitly pass --database-url and use --user-directory or --base-directory, the default DB location now follows the effective user directory. If an existing legacy install-directory user/comfyui.db is present and the new target DB is missing, it is copied once to avoid appearing to lose existing asset data.

Testing

  • .venv/bin/python -m pytest tests-unit/app_test/test_migrations.py tests-unit/app_test/database_path_test.py -q
  • .venv/bin/python -m ruff check .

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 509c65f9-d1e5-4246-8506-4910f8bf3080

📥 Commits

Reviewing files that changed from the base of the PR and between 374bb9a and 9789de0.

📒 Files selected for processing (3)
  • app/database/db.py
  • comfy/cli_args.py
  • tests-unit/app_test/database_path_test.py
✅ Files skipped from review due to trivial changes (1)
  • tests-unit/app_test/database_path_test.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • comfy/cli_args.py
  • app/database/db.py

📝 Walkthrough

Walkthrough

comfy/cli_args.py now records whether --database-url was explicitly passed on the command line. app/database/db.py resolves the effective database URL through new helper functions, derives the legacy comfyui.db path, prepares file-backed database directories, and copies a legacy database when needed before migrations. init_db() and _init_file_db() use the new helpers, and new unit tests cover URL resolution, directory creation, and legacy database copy behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: fixing the default database path for custom user directories.
Description check ✅ Passed The description accurately describes the database path fix, explicit URL preservation, and legacy DB copy behavior.
Linked Issues check ✅ Passed The changes address #14524 by resolving the SQLite DB path from the effective user/base directory and preserving explicit overrides.
Out of Scope Changes check ✅ Passed The modified files and added tests are directly related to the database path fix and legacy migration behavior.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Constantine1916 Constantine1916 force-pushed the fix/database-user-directory branch from 374bb9a to 9789de0 Compare June 26, 2026 03:08
@Constantine1916

Copy link
Copy Markdown
Author

Rebased this PR on the latest master and re-ran the related checks:

  • .venv/bin/python -m pytest tests-unit/app_test/test_migrations.py tests-unit/app_test/database_path_test.py -q
  • .venv/bin/python -m ruff check .

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.

user-directory and base-directory args being ignored in DB setup

2 participants