In the documentation for Realm Flutter, in no uncertain terms, it says: “Realm can automatically migrate added and deleted properties. You must update the schema version when you make these changes.” (https://www.mongodb.com/docs/realm/sdk/flutter/realm-database/model-data/update-realm-object-schema/#add-a-property).
I performed the following:
- Added the testProp field below:
@RealmModel()
class _SavedItem {
@PrimaryKey()
late String key;
@Indexed()
late String type;
late int itemId;
int trackingId = 0;
late String title;
late String? image;
late int? duration;
late String? subtitle;
late String? data;
List<int> topicIds = [];
List<String> topicNames = [];
late String? testProp;
}
- Ran
dart run realm generate
- Incremented the realmSchemaVersion in the code below
final realm = Realm(Configuration.local( [SavedItem.schema], schemaVersion: realmSchemaVersion, migrationCallback: (migration, oldSchemaVersion) {}, ));
Yet when I reopened my app, I was greeted with a RealmException, as shown below:
Is there anywhere I can check to see if I’m doing anything wrong? If I’m not doing anything wrong, why is the automatic migration which the documentation described not happening??