Nixos is very good at using different versions of software. But especially in services like databases new versions mean conversions.
Wouldn’t it be nice to have some kind of standard in Nixos to record the current versions in the filesystem, so the activationscript can handle the conversions?
It could be very simple: some directory with files, and a makefile filled with things like:
postgresql_22 : postgresql_21
do_postgresql_update_22
rm $^
(and vise versa...)
Or some file with a list of updates, you can diff to detect changes.
I know how to upgrade databases. It’s just “nixos upgrades cleanly” breaks down with services that need migration of some kind.
Your configuration expects some layout of it’s working data. This layout could be dependent on the software version. Some Disnomia-like construction could be used to track migrations of the mutable state.
I was in that discussion. And someone proposed to start a discussion on possible implementations for a replacement.
Creating the script framework could be relatively easy (as proposed: make could find upgrade paths from a wide range of old versions. But once I made something just with diff that worked)
But then the problems start: what if your upgrade fails… you have to build upgrade and downgrade-script. You don’t know the required upgrades until the system is activated…
Currently you’re asking “what could a script look like?”, not answering any of the questions about upgrade failures or rollbacks that made people skeptical of this approach, so this is just a repeat of the other 3 threads.
Rather than simply “discuss” approaches, someone needs to sit down and design a version policy and process for data migration that never results in broken systems.
“We could write a script” without saying what the script does is not that.
The script @bitbloxhub linked is how the data conversion is done, that’s the “easy” part.
If you can define a robust process for the rest, that’d be an excellent proposal, but what you seem to be proposing so far (just do what dysnomia does?) would fail under many edge cases in the wild.