Skip to content

Default to XDG config dir with migration from ~/.sqlit#180

Merged
Maxteabag merged 1 commit intomainfrom
xdg-config-dir
Apr 18, 2026
Merged

Default to XDG config dir with migration from ~/.sqlit#180
Maxteabag merged 1 commit intomainfrom
xdg-config-dir

Conversation

@Maxteabag
Copy link
Copy Markdown
Owner

@Maxteabag Maxteabag commented Apr 18, 2026

Fixes #174. Supersedes #129's docs change with an actual XDG default.

Before: config lived in ~/.sqlit/, with SQLIT_CONFIG_DIR as an undocumented escape hatch. #129's author and a commenter both spent time digging before finding it.

After: default is $XDG_CONFIG_HOME/sqlit (falling back to ~/.config/sqlit). SQLIT_CONFIG_DIR still wins if set.

Migration on first run:

  • Legacy ~/.sqlit absent → nothing to do.
  • New path absent → atomic rename of the whole tree.
  • New path exists but holds no core config (only side-effect cache files from aws/azure/gcp discovery, which this PR also fixes) → merge legacy entries in one-by-one, skipping collisions, then drop the empty legacy dir.
  • New path already holds core config → leave both sides alone so nothing gets clobbered.

Scope note on #174: the spec strictly splits config ($XDG_CONFIG_HOME) from data ($XDG_DATA_HOME). This PR puts everything under $XDG_CONFIG_HOME/sqlit for simplicity and to match how sqlit currently treats its data (one dir, one set of JSON files). If a stricter split is wanted later, it's a follow-up.

Drive-by fix: three cloud-discovery cache files (aws/azure/gcp/cache.py) previously hardcoded ~/.config/sqlit/, ignoring SQLIT_CONFIG_DIR. They now route through CONFIG_DIR like everything else.

Verified end-to-end: migrated my own ~/.sqlit (17 connections, query history, credentials, theme customizations) into ~/.config/sqlit with cache files preserved and legacy dir cleaned up. 8 new unit tests cover env-var precedence, XDG behavior, rename migration, merge migration, collision-skip, and no-op cases. Full unit suite (748 tests) still passes.

Closes #129 for the documentation piece.

Config now resolves to \$XDG_CONFIG_HOME/sqlit (falling back to
~/.config/sqlit); SQLIT_CONFIG_DIR still wins if set. Legacy ~/.sqlit
is migrated on first run:

- new path absent: atomic rename of the whole tree.
- new path exists but holds no core config (only e.g. the cloud-
  discovery caches that already wrote straight into ~/.config/sqlit):
  merge entries in one-by-one, skipping collisions, then drop the
  now-empty legacy dir.
- new path already holds core config (settings/connections/credentials):
  leave both sides alone so no user-edited files get clobbered.

Also fixes three pre-existing cache paths (aws/azure/gcp discovery)
that hardcoded ~/.config/sqlit and ignored SQLIT_CONFIG_DIR — now all
paths route through the resolved CONFIG_DIR.

User-visible mentions of ~/.sqlit in prompts, notifications and
docstrings are updated to refer to the sqlit config directory
generically, since the exact path varies by environment.

README updated to describe the new default and the migration.

Closes #129 for the documentation piece.
@Maxteabag Maxteabag merged commit b3caa5d into main Apr 18, 2026
21 checks passed
@Maxteabag Maxteabag deleted the xdg-config-dir branch April 18, 2026 18:15
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.

[Feature Request] Support XDG Base Directory specification

1 participant