You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes you need to parse and migrate data only up to a specific version, not all the way to the latest. This is particularly useful for recursive entity definitions where entities reference themselves. The `upTo` series of functions provide this capability.
155
+
156
+
#### Why Version-Bounded Migration?
157
+
158
+
Consider a recursive tree structure where nodes can contain child nodes. When migrating from v1 to v2, if you use regular `entityReference`, the children might be migrated to a future version (e.g., v3 or v4) that didn't exist when you wrote the v1→v2 migration. This can break your migration logic.
159
+
160
+
Version-bounded functions ensure that entities are only migrated up to a specific version, maintaining consistency in your migration functions.
161
+
162
+
#### Available Functions
163
+
164
+
-**`isUpToVersion(data, version)`** - Type guard that checks if data is valid for any version up to and including the specified version
165
+
-**`safeParseUpToVersion(data, version)`** - Parses and migrates data up to a specific version (not beyond)
166
+
-**`entityRefUptoVersion(entity, version)`** - Creates a Zod schema for version-bounded entity references
0 commit comments