I understand you need to add migration classes if you are going to add members to a class that is persisted in the db either via snapshot or event persistence. The only exception is for new Option class members. How about defs or functions? Can you add a new function to a class that has already been used hence, persisted in a previous deployment? Are functions included in serialization/deserialization of a class? Or are class functions generated from the latest deployed class code?
Migrations are for changing the serialized form of an object. As defs and functions are not serialized changing them does not require a migration. The only exception that I can imagine would be if the def were annotated to specifically affect the serialized form.
Thanks for clarifying that. Does this mean for case classes only the class parameters are serialized? Members defined in the body such as vars, vals, lazy vals are not serialized?
How a case class is serialized depends on the serializer implementation and configuration, so you’ll have to know your library and what optional features may be enabled or disabled. In general though serialization creates a JSON object, and that’s only going to include data values. Deserialization generally invokes a constructor with the JSON values mapped to constructor args. If your case class includes values that are not part of the constructor args and they need to be serialized you will probably implement some custom serialization/deserialization. That may be as simple as adding an annotation or may require custom classes.