Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the best way to handle configuration migration? #60

Open
philpax opened this issue Jun 28, 2022 · 4 comments
Open

What is the best way to handle configuration migration? #60

philpax opened this issue Jun 28, 2022 · 4 comments

Comments

@philpax
Copy link
Contributor

philpax commented Jun 28, 2022

Sometimes, you just gotta change how your config's being stored / what's being stored, but you want to make sure that you aren't going to lose user data while doing so. What's the cleanest way of doing this, preferably while remaining a nice and clean separation between versions?

This seems like it might be a bit complicated because the Configuration is automatically de/serialised - how do you gracefully choose to deserialise with a ConfigurationV1, convert to a ConfigurationV2, and serialise with the ConfigurationV2?

@karashiiro
Copy link
Contributor

karashiiro commented Jun 28, 2022

I actually have migration classes which run on load and handle this. It's a bit messy, but it works as long as you think it through thoroughly, accounting for all the previous versions a user could be jumping from (which is not ideal).

@karashiiro
Copy link
Contributor

See here.

@karashiiro
Copy link
Contributor

Also note all of the obsolete fields required for proper loading.

@philpax
Copy link
Contributor Author

philpax commented Jun 28, 2022

Yeah, that's all I can think of as well with the current system (outside of like... having explicit v1: ConfigurationV1 fields). Bit of a shame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants