Skip to content

fix(database): support upstream schema 27 for sync restore (#576) - #578

Merged
SaladDay merged 2 commits into
SaladDay:mainfrom
NorthSecond:fix/upstream-schema-27-compat
Nov 24, 2026
Merged

SaladDay merged 2 commits into
SaladDay:mainfrom
NorthSecond:fix/upstream-schema-27-compat

Conversation

@NorthSecond

Copy link
Copy Markdown
Contributor

Summary

Adds upstream schema 27 (CC Switch desktop v4.0.36–v4.0.40) to the CLI's accepted range, following the same pattern used to adopt schemas 21–26. Fixes Remote database schema is too new (27); this app supports up to 26 when restoring WebDAV/S3 snapshots from recent desktop releases. Addresses #576.

 on(restore snapshot)
-  accept user_version <= 26
+  accept user_version <= 27
   reject newer  → "too new"

The upstream change is two columns on the skill-repository tables:

 skills
+  repo_host TEXT NULL            -- v27, GitLab/etc. host
 skill_repos
+  host TEXT NOT NULL DEFAULT 'github.com'  -- v27

The CLI has no GitLab skill-repo management, so it only aligns the columns and keeps upstream-owned values intact:

  • save_skill_repo switched from INSERT OR REPLACE to an explicit ON CONFLICT(owner, name) DO UPDATE, so a load_index → save_index round-trip no longer resets a synced GitLab repo's host back to github.com.
  • save_skill already lists explicit columns, so repo_host is untouched.
  • Sync export reads columns via PRAGMA table_info, so both columns flow through snapshots automatically.

Evidence

  • Before: import_sql_string_for_sync on a user_version = 27 snapshot fails in validate_sql_user_version_for_import with Remote database schema is too new (27).
    After: the snapshot validates and restores.

  • cargo test --lib --no-default-features -- database::tests sync_protocol webdav_sync → 106 passed; 0 failed, including new cases:

    • schema_migration_upstream_v18_through_v27_preserves_data_and_is_idempotent
    • init_and_sync_import_accept_upstream_v18_through_v27
    • skill_dao_save_preserves_upstream_repo_host / skill_repo_save_preserves_upstream_host
    • schema_create_tables_matches_upstream_v27_flags
  • cargo fmt --check clean; cargo check --lib --no-default-features clean (only pre-existing warnings in unrelated files).

Merge Danger

Door: two-way

Rollback is a revert; the added columns are inert defaults (github.com / NULL) for the CLI and older code ignores them. Note: after a device migrates to schema 27, CLI ≤ v5.11.4 can no longer open that database (documented in CHANGELOG upgrade notes).

Blast Radius: sync restore

Touches schema versioning, fresh-table DDL, one migration step, one DAO write path, and test fixtures. No behaviour change for users already at ≤ 26; databases newer than 27 are still rejected.

Notes

Database compatibility only — no GitLab skill-repository management is added. Upstream's unreleased schema 28 is intentionally out of scope.

)

Desktop v4.0.36-v4.0.40 write schema 27, but the CLI only supported up
to schema 26, so WebDAV/S3 restore rejected the snapshot with
"Remote database schema is too new (27); this app supports up to 26".

Align the fresh-table DDL and add a 26->27 migration for the upstream
GitLab skill repository columns (skill_repos.host with default
'github.com', skills.repo_host nullable), idempotent and tolerant of
absent tables. Switch save_skill_repo to an explicit upsert so it only
writes the CLI-managed columns and no longer resets host back to
github.com on a load_index -> save_index round-trip. Extend fixtures and
tests through schema 27 and cover both DAO write paths and the sync
round-trip. Document in both CHANGELOGs.

Adds database compatibility only, not GitLab skill repository
management. Databases newer than schema 27 are still rejected.

Co-authored-by: NorthSecond <NorthSecond@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T10:22:08.799924Z 949e62b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@NorthSecond NorthSecond changed the title fix(database): support upstream schema 27 for sync restore fix(database): support upstream schema 27 for sync restore (#576) Nov 24, 2026
The CLI only talks to GitHub. Hide non-GitHub skill repos synced from desktop (schema 27 host) and skip/refuse updates for skills installed from them, so they are never fetched from github.com. Also correct the desktop version range to v4.0.34-v4.0.40.
@SaladDay
SaladDay merged commit c81e88e into SaladDay:main Nov 24, 2026
6 checks passed
@SaladDay

Copy link
Copy Markdown
Owner

Thanks for the fix! I pushed a small follow-up so the CLI leaves GitLab repos alone, and it's merged now.

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.

2 participants