Support reversible migrations: target schema, missing-down error, docs and tests #228
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
downhandler is missing so startup does not hang or silently corrupt data.downand behavior is verified.Description
targetVersionparameter torunMigrationsand implemented downgrade logic that appliesdownhandlers in reverse order whenstoredVersion > targetVersion, updating the stored version after each rollback (apps/desktop/src/main/store/migrations/index.ts).MissingDownMigrationErrorto represent missingdownhandlers and re-exported it from the migrations module (apps/desktop/src/main/store/migrations/errors.ts).downimplementation for the initial migration (v001) to provide a rollback path for legacy installs (apps/desktop/src/main/store/migrations/v001-initial.ts).MissingDownMigrationErrorin the Electron bootstrap and showing a user-facing dialog titledDowngrade Not Supportedbefore quitting (apps/desktop/src/main/index.ts).CLAUDE.md) to mandatedownhandlers in new migration templates and call out addingdownhandlers for legacy migrations when enabling downgrade support.apps/desktop/__tests__/unit/main/store/migrations.unit.test.ts).Testing
pnpm -F @accomplish/desktop test:unit -- __tests__/unit/main/store/migrations.unit.test.ts, which exercised forward upgrade, downgrade, re-upgrade, and the unknown-schema (FutureSchemaError) case; these tests passed.Codex Task