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

add versioned migrations #1644

Merged
merged 1 commit into from
Dec 10, 2023
Merged

Conversation

kradalby
Copy link
Collaborator

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.

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.

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
@kradalby kradalby added this to the v0.23.0 milestone Dec 10, 2023
@kradalby kradalby merged commit 6049ec7 into juanfont:main Dec 10, 2023
46 checks passed
@kradalby kradalby deleted the gomigrations-init branch December 10, 2023 14:46
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

Successfully merging this pull request may close these issues.

2 participants