Skip to content

Schema downgrades fail (from future schema versions) #1427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gnprice opened this issue Mar 21, 2025 · 0 comments · Fixed by #1428
Closed

Schema downgrades fail (from future schema versions) #1427

gnprice opened this issue Mar 21, 2025 · 0 comments · Fixed by #1428
Assignees
Labels
a-model Implementing our data model (PerAccountStore, etc.) a-tools Our own development tooling, scripts, and infrastructure

Comments

@gnprice
Copy link
Member

gnprice commented Mar 21, 2025

In #1416, we should have adjusted AppDatabase._dropAndCreateAll to reflect the change that PR made to the onCreate in migration, making it insert the GlobalSettings row.

(Originally noticed this at #1421 (comment) .)

Without that adjustment, if you switch to a branch (like #1421) with a later schema version, then back to schema version 5 — only really possible as a developer — you get this error at startup:

E/flutter (15620): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: Bad state: No element
E/flutter (15620): #0      List.single (dart:core-patch/growable_array.dart:358:22)
E/flutter (15620): #1      Selectable.getSingle (package:drift/src/runtime/query_builder/statements/query.dart:239:26)
E/flutter (15620): <asynchronous suspension>
E/flutter (15620): #2      AppDatabase.getGlobalSettings (package:zulip/model/database.dart:186:12)
E/flutter (15620): <asynchronous suspension>
E/flutter (15620): #3      LiveGlobalStore.load (package:zulip/model/store.dart:886:28)
E/flutter (15620): <asynchronous suspension>
E/flutter (15620): #4      _GlobalStoreWidgetState.initState.<anonymous closure> (package:zulip/widgets/store.dart:89:21)
E/flutter (15620): <asynchronous suspension>

and the app fails to get past the loading screen.

Workaround

To unwedge from that state, you can switch to a version before schema version 5 (e.g., to this week's v0.0.27 release) and then forward again; or uninstall the app and reinstall.

@gnprice gnprice self-assigned this Mar 21, 2025
@gnprice gnprice added a-tools Our own development tooling, scripts, and infrastructure a-model Implementing our data model (PerAccountStore, etc.) labels Mar 21, 2025
@gnprice gnprice added this to the M5a: Launch blockers milestone Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-model Implementing our data model (PerAccountStore, etc.) a-tools Our own development tooling, scripts, and infrastructure
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant