# Data conversion

**URL:** https://discourse.nixos.org/t/data-conversion/77890
**Category:** Development
**Created:** [May 28, 2026, 2:15pm UTC](https://discourse.nixos.org/t/data-conversion/77890 "2026-05-28T14:15:40Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![frank87](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/f/8e8cbc/32.png) [@frank87](https://discourse.nixos.org/u/frank87)
#### Post date: [May 28, 2026, 2:15pm UTC](https://discourse.nixos.org/t/data-conversion/77890/1 "2026-05-28T14:15:40Z")

</div>

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:

```auto
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.

```

---

<div class="post-metadata">

### Author: ![mightyiam](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mightyiam/32/33998_2.png) [@mightyiam](https://discourse.nixos.org/u/mightyiam)
#### Post date: [May 28, 2026, 2:31pm UTC](https://discourse.nixos.org/t/data-conversion/77890/2 "2026-05-28T14:31:05Z")

</div>

Does the NixOS Postgres module have no migration story?

---

<div class="post-metadata">

### Author: ![frank87](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/f/8e8cbc/32.png) [@frank87](https://discourse.nixos.org/u/frank87)
#### Post date: [May 28, 2026, 2:39pm UTC](https://discourse.nixos.org/t/data-conversion/77890/3 "2026-05-28T14:39:56Z")

</div>

Don’t think so. The default package for postgresql is decided by system.stateVersion…

---

<div class="post-metadata">

### Author: ![bitbloxhub](https://discourse.nixos.org/user_avatar/discourse.nixos.org/bitbloxhub/32/35210_2.png) [@bitbloxhub](https://discourse.nixos.org/u/bitbloxhub)
#### Post date: [May 28, 2026, 4:05pm UTC](https://discourse.nixos.org/t/data-conversion/77890/4 "2026-05-28T16:05:46Z")

</div>

> **[Upgrading - NixOS Manual](https://nixos.org/manual/nixos/stable/#module-services-postgres-upgrading)**
>
> The steps below demonstrate how to upgrade from an older version to pkgs.postgresql\_15. These instructions are also applicable to other versions.

This script should help you.

---

<div class="post-metadata">

### Author: ![waffle8946](https://discourse.nixos.org/user_avatar/discourse.nixos.org/waffle8946/32/27221_2.png) [@waffle8946](https://discourse.nixos.org/u/waffle8946)
#### Post date: [May 28, 2026, 6:22pm UTC](https://discourse.nixos.org/t/data-conversion/77890/6 "2026-05-28T18:22:23Z")

</div>

Third time it’s been discussed in the last month, I think we can look at the existing discussions 🙂

> [@Incrementally salvaging stateVersion](https://discourse.nixos.org/t/incrementally-salvaging-stateversion/76848):
>
> system.stateVersion is widely acknowledged to be an imperfect thing. I’d like to propose incrementally augmenting it with a less imperfect thing. Problems I want to address: Users, new and old, perennially want to update system.stateVersion. We can tell them not to until we’re blue in the face, but there’s a certain kind of OCD computer toucher who simply cannot allow anything that looks like a date in their system config to be more than a year old; and the NixOS community has, I would wager,…

> [@Unpopular opinion: Maybe \`stateVersion\` shouldn't exist at all](https://discourse.nixos.org/t/unpopular-opinion-maybe-stateversion-shouldnt-exist-at-all/77048):
>
> Hello there. First, I must say that I am just an ordinary NixOS user, not a module maintainer, and certainly not an experienced expert user, so my perspective may therefore be highly one-sided. And second, I must clarify that the title is not intended to disparage the hard work of the module maintainers. For the reasons behind this statement, please read on. Today, I spent several hours investigating exactly what purpose stateVersion serves. I even attempted to use hands-on experimentation to c…

---

<div class="post-metadata">

### Author: ![frank87](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/f/8e8cbc/32.png) [@frank87](https://discourse.nixos.org/u/frank87)
#### Post date: [May 28, 2026, 8:30pm UTC](https://discourse.nixos.org/t/data-conversion/77890/7 "2026-05-28T20:30:17Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![frank87](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/f/8e8cbc/32.png) [@frank87](https://discourse.nixos.org/u/frank87)
#### Post date: [May 28, 2026, 8:38pm UTC](https://discourse.nixos.org/t/data-conversion/77890/8 "2026-05-28T20:38:55Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![frank87](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/f/8e8cbc/32.png) [@frank87](https://discourse.nixos.org/u/frank87)
#### Post date: [May 28, 2026, 8:43pm UTC](https://discourse.nixos.org/t/data-conversion/77890/9 "2026-05-28T20:43:56Z")

</div>

A lot of the gory details could be copied from dysnomia: backing up before migration, standard in the updating process.

The only part missing is de data conversion itself.

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tlater/32/4257_2.png) [@TLATER](https://discourse.nixos.org/u/TLATER)
#### Post date: [May 29, 2026, 3:31am UTC](https://discourse.nixos.org/t/data-conversion/77890/10 "2026-05-29T03:31:29Z")

</div>

> [@frank87](#):
>
> I was in that discussion. And someone proposed to start a discussion on possible implementations for a replacement.

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.

> [@frank87](#):
>
> The only part missing is de data conversion itself.

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.

---

<div class="post-metadata">

### Author: ![frank87](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/f/8e8cbc/32.png) [@frank87](https://discourse.nixos.org/u/frank87)
#### Post date: [May 30, 2026, 11:24am UTC](https://discourse.nixos.org/t/data-conversion/77890/11 "2026-05-30T11:24:35Z")

</div>

Sorry for not following the discussion close enough…
