Skip to content

Commit

Permalink
Update usage-filestate.md
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLeif authored Sep 27, 2024
1 parent 78a39ae commit 19e31a9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions documentation/usage-filestate.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ struct LargeDataView: View {
}
```

### Migration Considerations

When updating your data model, it's important to account for potential migration challenges, especially when working with persisted data using **StoredState**, **FileState**, or **SyncState**. Without proper migration handling, changes like adding new fields or modifying data formats can cause issues when older data is loaded.

Here are some key points to keep in mind:
- **Adding New Non-Optional Fields**: Ensure new fields are either optional or have default values to maintain backward compatibility.
- **Handling Data Format Changes**: If the structure of your model changes, implement custom decoding logic to support old formats.
- **Versioning Your Models**: Use a `version` field in your models to help with migrations and apply logic based on the data’s version.

To learn more about how to manage migrations and avoid potential issues, refer to the [Migration Considerations Guide](migration-considerations.md).


## Best Practices

- **Use for Large or Complex Data**: If you're storing large data or complex objects, `FileState` is ideal over `StoredState`.
Expand Down

0 comments on commit 19e31a9

Please sign in to comment.