Skip to content

fix: add SQLite schema versioning for future migrations#594

Merged
datlechin merged 1 commit intomainfrom
fix/sqlite-schema-versioning
Apr 6, 2026
Merged

fix: add SQLite schema versioning for future migrations#594
datlechin merged 1 commit intomainfrom
fix/sqlite-schema-versioning

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

Adds PRAGMA user_version-based schema migration infrastructure to both SQLite databases (query_history.db and sql_favorites.db).

Both databases currently use CREATE TABLE IF NOT EXISTS with no version tracking. If a future release needs to add a column, existing users would silently keep the old schema. This PR sets the foundation so future schema changes can use ALTER TABLE ... ADD COLUMN migrations gated by version checks.

Changes:

  • QueryHistoryStorage.swift — Added migrateIfNeeded(), getUserVersion(), setUserVersion(). Current schema set to version 1.
  • SQLFavoriteStorage.swift — Same three methods added. Current schema set to version 1.

No schema changes are made — this just stamps the current schema as version 1 so future migrations have a baseline.

Addresses audit item C5.

Test plan

  • Fresh launch: sqlite3 ~/Library/Application\ Support/TablePro/query_history.db "PRAGMA user_version;" returns 1
  • Fresh launch: sqlite3 ~/Library/Application\ Support/TablePro/sql_favorites.db "PRAGMA user_version;" returns 1
  • Query history works normally (execute queries, search history)
  • SQL favorites work normally (create/edit/delete favorites and folders)
  • Existing tests pass

@datlechin datlechin merged commit 8b220f1 into main Apr 6, 2026
2 checks passed
@datlechin datlechin deleted the fix/sqlite-schema-versioning branch April 6, 2026 06:07
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.

1 participant