You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CLI: back up cli.db on upgrade and add a command to undo an upgrade #1623
Follow-up from #1612, suggested by @BYK in review.
Problem
Older CLIs only migrate cli.db forward. When a user moves from a newer CLI back to an older one (for example nightly → stable with sentry cli upgrade stable), the older CLI finds a database it can't read (#1611). #1612 handles this by having the newer CLI reset the database before the older one runs: it clears cache tables and stored accounts and sets the schema version back to 16. That works, but the user has to log in again, and every migration after v16 has to be safe to re-run.
Proposal
Restore a saved copy instead of reverting the database in code:
Before sentry cli upgrade installs a different version, copy cli.db to a backup and record the version being replaced.
Add a command, such as sentry cli upgrade undo or sentry cli revert, that reinstalls the recorded version and restores the backed-up database.
The user goes back to the exact database the older CLI last used, login included, and newer CLIs don't need to know older schemas.
Open questions
Stale data: logins or token refreshes made on the newer version are lost when the backup is restored. Should we warn, or merge accounts back in?
Retention: keep only the most recent backup, or one per version?
Stale data: logins or token refreshes made on the newer version are lost when the backup is restored. Should we warn, or merge accounts back in?
Merge when possible, warn at least.
Retention: keep only the most recent backup, or one per version?
One per version
Other install methods: what about downgrades that don't go through cli upgrade, like npm or brew pinning? Those still need the newer-schema handling from #1612.
Yes. Warn if we can but it's up to the users at that point. We can try pre/post install scripts etc but they are normally blocked now for security (rightly so)
Secrets: backups contain refresh tokens, so they need the same file permissions as cli.db.
Activity
linear-code commentedon Oct 23, 2026
MCP-1123
BYK commentedon Oct 23, 2026
Merge when possible, warn at least.
One per version
Yes. Warn if we can but it's up to the users at that point. We can try pre/post install scripts etc but they are normally blocked now for security (rightly so)
Sounds good? Don't see a question here?
feat(cli): Back up the database on upgrade and add `cli upgrade undo`
fix(cli): Keep the local database usable across CLI downgrades (#1612)
feat(cli): Back up the database on upgrade and add `cli upgrade undo`
feat(cli): Back up the database on upgrade and add `cli upgrade undo` (…