JetBrains / xodus-dnq

Data definition and queries Kotlin DSL over Xodus
Apache License 2.0
86 stars 25 forks source link

Migration / versions of data definitions #71

Open Jorgen-P opened 3 years ago

Jorgen-P commented 3 years ago

I can't find any documentation about or example of changing definitions for data and migrating old data to it. Would you create a new class and migrate the data in the application with no direct support from xodus-dnq? Would you have to move everything linked to new definitions as well?

lehvolk commented 3 years ago

We recommend to write application code for data migration.

Renaming entity type, property or link

You can use aliases for all properties, links, blobs and entity types. Like var email by xdStringProp(dbName="_email_") or object : XdNaturalEntityType("OldDeprecatedName")

Data structure migration

This is the most problematic case. When you run application with new model definition you should apply new model definition to the database. It's better to do as a separate startup step. Migration code will use only new model definition so cascade operations from old model definition should be applied manually.

We can give some recommendations:

I will add this into our documentation somewhere.

Jorgen-P commented 3 years ago

Thank you for the advice.