# Automatic database schema updates

**URL:** https://discourse.nixos.org/t/automatic-database-schema-updates/5836
**Category:** Development
**Created:** [February 10, 2020, 11:37am UTC](https://discourse.nixos.org/t/automatic-database-schema-updates/5836 "2020-02-10T11:37:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![aanderse](https://discourse.nixos.org/user_avatar/discourse.nixos.org/aanderse/32/1420_2.png) [@aanderse](https://discourse.nixos.org/u/aanderse)
#### Post date: [February 10, 2020, 11:37am UTC](https://discourse.nixos.org/t/automatic-database-schema-updates/5836/1 "2020-02-10T11:37:50Z")

</div>

Please state your opinion, and preferably reasoning. why you think NixOS modules should automatically run database schema updates or not.

Some relevant discussion points:

- Some software doesn’t give you a choice and run schema updates automatically when the main binary starts.
- Numerous modules in NixOS automatically run schema updates, while others do not.
- At least several pieces of software in NixOS which don’t run schema updates automatically do **not** mention the need to run schema updates manually, sometimes resulting in failures which go unnoticed for a while.
- Database schemas can take a while to run and often times can’t be backed out, leaving the unprepared sysadmin with a headache when things go wrong.

I don’t think we have an official stance on whether automatically running schema updates is the right thing to do or not so I would love to hear everyone’s thoughts and opinions.

Thanks!

---

<div class="post-metadata">

### Author: ![FRidh](https://discourse.nixos.org/user_avatar/discourse.nixos.org/fridh/32/7643_2.png) [@FRidh](https://discourse.nixos.org/u/FRidh)
#### Post date: [February 10, 2020, 12:02pm UTC](https://discourse.nixos.org/t/automatic-database-schema-updates/5836/2 "2020-02-10T12:02:15Z")

</div>

Is it possible to perform a database schema update revert in case of a NixOS rollback?

---

<div class="post-metadata">

### Author: ![dalto](https://discourse.nixos.org/user_avatar/discourse.nixos.org/dalto/32/2176_2.png) [@dalto](https://discourse.nixos.org/u/dalto)
#### Post date: [February 10, 2020, 1:29pm UTC](https://discourse.nixos.org/t/automatic-database-schema-updates/5836/3 "2020-02-10T13:29:31Z")

</div>

It feels situational to me. The impact and level of risk associated with schema updates varies greatly between applications.

I guess my stance would be “modules _should_ perform database schema updates unless there is a compelling reason not to”

Why:

- If manual intervention is required on updates, how do we notify of that and what happens in the case of unattended upgrades
- Sometimes schema updates are required for the software to continue to function post-upgrade
- Forcing schema updates puts everyone running the software in a consistent state. i.e. You shouldn’t get strange bug reports because someone forgot to do the schema update.

I suppose an alternative would be for it to somehow be optional
