@@ -8,6 +8,28 @@ import 'modelentity.dart';
88const _minModelVersion = 5 ;
99const _maxModelVersion = 5 ;
1010
11+ /// Represents the generator version used to create the model.
12+ ///
13+ /// This enum contains all supported versions by this ObjectBox runtime library.
14+ /// It is used purely for compile-time enforcement to ensure users regenerate
15+ /// code after updating the objectbox package.
16+ /// Once a version is not compatible/supported, it is removed from this enum.
17+ /// Note: using a separate, date based, versioning (YYYY_MM_DD) as the
18+ /// generator is not always updated in each library version.
19+ enum GeneratorVersion {
20+ /// The model was not created by generated code.
21+ none,
22+
23+ /// BREAKING CHANGE in ObjectBox Dart 5.1 with DateTime (date) properties:
24+ /// - DateTime properties are now stored in UTC by default(!).
25+ /// - If you rely on reading local time, you must use dateLegacy.
26+ /// - Only UTC times provide correct values for ObjectBox Sync.
27+ v2025_12_16,
28+ }
29+
30+ /// The latest generator version (aligned with this ObjectBox runtime library).
31+ const generatorVersionLatest = GeneratorVersion .v2025_12_16;
32+
1133/// In order to represent the model stored in `objectbox-model.json` in Dart,
1234/// several classes have been introduced. Conceptually, these classes are
1335/// comparable to how models are handled in ObjectBox Java and ObjectBox Go.
@@ -20,6 +42,9 @@ class ModelInfo {
2042 'If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.' ,
2143 ];
2244
45+ /// The ObjectBox Dart generator version used to generate this model.
46+ GeneratorVersion generatorVersion;
47+
2348 List <ModelEntity > entities;
2449 IdUid lastEntityId, lastIndexId, lastRelationId, lastSequenceId;
2550 List <int > retiredEntityUids,
@@ -29,7 +54,8 @@ class ModelInfo {
2954 int modelVersion, modelVersionParserMinimum, version;
3055
3156 ModelInfo (
32- {required this .entities,
57+ {required this .generatorVersion,
58+ required this .entities,
3359 required this .lastEntityId,
3460 required this .lastIndexId,
3561 required this .lastRelationId,
@@ -43,7 +69,8 @@ class ModelInfo {
4369 required this .version});
4470
4571 ModelInfo .empty ()
46- : entities = [],
72+ : generatorVersion = GeneratorVersion .none,
73+ entities = [],
4774 lastEntityId = const IdUid .empty (),
4875 lastIndexId = const IdUid .empty (),
4976 lastRelationId = const IdUid .empty (),
@@ -57,7 +84,8 @@ class ModelInfo {
5784 version = 1 ;
5885
5986 ModelInfo .fromMap (Map <String , dynamic > data, {bool check = true })
60- : entities = [],
87+ : generatorVersion = GeneratorVersion .none,
88+ entities = [],
6189 lastEntityId = IdUid .fromString (data['lastEntityId' ] as String ? ),
6290 lastIndexId = IdUid .fromString (data['lastIndexId' ] as String ? ),
6391 lastRelationId = IdUid .fromString (data['lastRelationId' ] as String ? ),
0 commit comments