[PR #1644] [MERGED] add versioned migrations #2232

Closed
opened 2025-12-29 03:20:19 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/1644
Author: @kradalby
Created: 12/10/2023
Status: Merged
Merged: 12/10/2023
Merged by: @kradalby

Base: mainHead: gomigrations-init


📝 Commits (1)

📊 Changes

6 files changed (+241 additions, -244 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 flake.nix (+1 -1)
📝 go.mod (+1 -0)
📝 go.sum (+2 -0)
📝 hscontrol/db/db.go (+235 -242)
📝 hscontrol/types/node.go (+1 -1)

📄 Description

Up until this commit, headscale has had one massive migration func that runs every time the server starts. This means that every time we have migrated anything, we have added stuff to it and not really taken into account how the database of clients look like. This means that sometimes the new stuff has had to be added in the middle, as it would break things further down.

It is kind of a miracle that it has worked so far with no permament damage, particularly considering some of our larger migrations like Machine -> Node or Namespace -> User.

This commit addresses this by adding gormigrate, which is a simple versioned migration system. As we have to maintain our messy past, the first migration is the large, currently working, but hard to change function. Subsequent changes should be added with new IDs after this.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/juanfont/headscale/pull/1644 **Author:** [@kradalby](https://github.com/kradalby) **Created:** 12/10/2023 **Status:** ✅ Merged **Merged:** 12/10/2023 **Merged by:** [@kradalby](https://github.com/kradalby) **Base:** `main` ← **Head:** `gomigrations-init` --- ### 📝 Commits (1) - [`8768eaa`](https://github.com/juanfont/headscale/commit/8768eaae7fd8e173ce30f121b9ca8571ad05ae6c) add versioned migrations ### 📊 Changes **6 files changed** (+241 additions, -244 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `flake.nix` (+1 -1) 📝 `go.mod` (+1 -0) 📝 `go.sum` (+2 -0) 📝 `hscontrol/db/db.go` (+235 -242) 📝 `hscontrol/types/node.go` (+1 -1) </details> ### 📄 Description Up until this commit, headscale has had one massive migration func that runs every time the server starts. This means that every time we have migrated anything, we have added stuff to it and not really taken into account how the database of clients look like. This means that sometimes the new stuff has had to be added in the middle, as it would break things further down. It is kind of a miracle that it has worked so far with no permament damage, particularly considering some of our larger migrations like Machine -> Node or Namespace -> User. This commit addresses this by adding gormigrate, which is a simple versioned migration system. As we have to maintain our messy past, the first migration is the large, currently working, but hard to change function. Subsequent changes should be added with new IDs after this. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 03:20:19 +01:00
adam closed this issue 2025-12-29 03:20:19 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2232