In a distributed environment, data structures, schemas, and documents organically undergo changes over time, which can lead to data inconsistencies.
Practice | Description |
---|---|
Standard naming conventions | Establish consistent naming rules. |
Forward-compatibility | Do not change types of existing fields. Introduce new fields instead. |
Validation and transformation | Ensure data validation and transformation procedures are in place. |
Upgrade notifications | Implement a system to notify users about schema upgrades. |
schema_version = {number}
as a convention to specify the
collection schema version your app will be listening to. Then, in your
application, you can be sure that you are only selecting documents that come from
schema versions that your current application code can support.
schema_version
that is greater than the current version. If a new version is
detected, stop sync and tell the user they need to upgrade their app to the
latest version.