Skip to content

Conversation

@kradalby
Copy link
Collaborator

@kradalby kradalby commented Nov 12, 2025

This PR add a new init schema function to quickly create the correct schema for an empty database/new installation.

In addition, it drops all upgrade support for migrating from before 0.25. This should not be any problem as we require all users to upgrade one version at a time.

Pre-0.24.0 databases lack migrations table, causing InitSchema
to run instead of migrations. Remove these test schemas as they
are incompatible with the current migration system.
Remove test cases for 0.22.3 schemas that lack migrations table.
These schemas trigger InitSchema instead of migrations, leaving
old tables (routes, machines) that fail schema validation.
Pre-commit hook was using system golangci-lint (Go 1.24) which is
incompatible with Go 1.25. Use nix develop to ensure correct version.
Remove test schemas for versions 0.10-0.23 to reduce maintenance
burden and focus testing on post-migration versions (0.24.0+).
Remove test cases for 0.23.0 to 0.24.0 migrations to reduce
maintenance burden and focus testing on current schema versions.
Add InitSchema function to initialize database schema from scratch
using GORM AutoMigrate. Handles index creation with proper formatting
to match schema.sql exactly, including partial indexes that GORM
cannot create automatically.
Add migration to convert multi-line user identity indexes to
single-line format for consistency with schema validation. Update
schema.sql and InitSchema to match single-line format.
Document that direct upgrades from databases before 0.24.0 are no
longer supported. Users must upgrade through an intermediate version.
Note that migrations before 0.28.0 will be removed in 0.29.
@kradalby kradalby force-pushed the kradalby/init-schema branch from 525de1a to 3d5d5e0 Compare November 13, 2025 00:36
@kradalby kradalby force-pushed the kradalby/init-schema branch from 3d5d5e0 to fabbe17 Compare November 13, 2025 01:20
kradalby added a commit to kradalby/headscale that referenced this pull request Nov 13, 2025
Remove support for direct upgrades from databases created before
version 0.25.0. Users on older versions must upgrade to v0.25.1
first before upgrading to this version.

This removes:
- All v0.24.0 migration functions (202407191627, 202408181235, 202409271400)
- Pre-v0.24.0 PostgreSQL test database dump
- Wrongly-migrated v0.25.1 test case and data
- tailscale.com/util/set import (no longer used)

Updates CHANGELOG.md to reflect the new minimum supported version.

Fixes juanfont#2883
@kradalby kradalby force-pushed the kradalby/init-schema branch from fabbe17 to 5c9daf1 Compare November 13, 2025 01:22
@kradalby kradalby changed the title hscontrol/db: add init schema, drop pre-0.24 support hscontrol/db: add init schema, drop pre-0.25 support Nov 13, 2025
Remove support for direct upgrades from databases created before
version 0.25.0. Users on older versions must upgrade to v0.25.1
first before upgrading to this version.

This removes:
- All v0.24.0 migration functions (202407191627, 202408181235, 202409271400)
- Pre-v0.24.0 PostgreSQL test database dump
- Wrongly-migrated v0.25.1 test case and data
- tailscale.com/util/set import (no longer used)

Updates CHANGELOG.md to reflect the new minimum supported version.

Fixes juanfont#2883
@kradalby kradalby marked this pull request as ready for review November 13, 2025 01:26
@kradalby kradalby force-pushed the kradalby/init-schema branch from 5c9daf1 to 18ce0e4 Compare November 13, 2025 01:29
@kradalby kradalby merged commit 75247f8 into juanfont:main Nov 13, 2025
96 of 98 checks passed
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