Can WatermelonDB's migration framework safely rollback after a schema change in React Native?
0 reputation · 12 Jul 2025, 19:45 UTC
Schema Migration Rollback Safety in WatermelonDB
WatermelonDB provides a structured migration system with schema versioning that automatically executes migrations when the schema version increases. The framework supports migration functions that can transform existing data to conform to new schema requirements.
However, the documentation does not clearly specify whether rollback scenarios are supported when a schema change has already been applied and persisted to the database. When developers need to revert a migration after users have already upgraded to a newer schema version, the behavior becomes unclear.
The key constraint is that WatermelonDB's migration system is designed for forward progression, with each migration incrementing the schema version number. There is no documented mechanism for decrementing the schema version or automatically reverting database transformations that have already been applied.
What specific rollback strategies does WatermelonDB recommend when a migration needs to be undone after deployment? Does the framework provide any built-in safeguards or should developers implement custom backup mechanisms before applying schema changes? How does WatermelonDB handle cases where different app versions with different schema versions coexist in the same database file?