Questions about data structures and migrations

The migration step can be handled in the pre and post upgrade methods, described here:

https://sdk.dfinity.org/docs/language-guide/upgrades.html

Keep in mind that preupgrade will fire from the code that’s previously installed and postupgrade will execute your incoming code changes.

You can use these to build any steps needed to migrate your old data structures to your new ones.