Menu

$$$$$$BACKUP FOR | Shipping a Safe Rollback: Downgrading a Drift (SQLite) Database in Flutter Without Losing User Data
📰

$$$$$$BACKUP FOR | Shipping a Safe Rollback: Downgrading a Drift (SQLite) Database in Flutter Without Losing User Data

DEV Community: mobile·George Ikwegbu Chinedu·about 4 hours ago
#uUyPjfQm
#devtomobile#devto#dev#fullscreen#schema
Reading 0:00
15s threshold

You're about to ship a release that bumps your local database schema. Being careful, you also prepare a rollback build , the version currently in production, so that if the new release has problems you can push the old one straight back out.

Then you test the rollback, and it crashes on startup.

This post covers:

Why Drift refuses to "upgrade" to a lower schema version

The fix (and why the obvious fix doesn't work)

A bug that's easy to introduce while making the fix

The git worktree workflow for building both versions side by side

Building three test APKs so QA can test upgrade → rollback → re-upgrade without losing data

All names, branches and paths below are made up for the article.

The setup

Production ( v1.4.1 ) uses database schema 11 .

The new release ( v1.5.0 , branch feature/new-release ) moves to schema 12 .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.