[PR #5182] [CLOSED] Fix MySQL 8 migration failure on indexed string columns #25188

Open
opened 2026-08-05 06:09:39 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/5182
Author: @codingbot24-s
Created: 1/26/2026
Status: Closed

Base: mainHead: fix/mysql-index-migration


📝 Commits (1)

  • e648763 Fix MySQL 8 migration failure on indexed string columns

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 management/server/peer/peer.go (+1 -1)

📄 Description

Describe your changes

This PR fixes a MySQL 8 / Aurora migration failure that occurs when upgrading NetBird from v0.62 to v0.63+. Older versions defined indexed string columns (e.g. Peer.Key) without explicit size constraints. During upgrades, GORM AutoMigrate attempts to convert these indexed VARCHAR columns into LONGTEXT, which MySQL does not allow without a key length, resulting in Error 1170 and management service startup failure.
The fix explicitly defines a fixed VARCHAR size for indexed string fields to
prevent GORM from converting them to TEXT/LONGTEXT during migrations.

Fixes #5171
https://github.com/netbirdio/netbird/issues/5171

Stack

Checklist

  • [X ] Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • [X ] Documentation is not needed for this change (explain why)
    This change only affects internal database migrations and does not introduce any user-facing configuration or behavioral changes.

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

Reproduced using MySQL 8.0 by upgrading schema created with v0.62 to v0.64.0.

Summary by CodeRabbit

  • Chores
    • Enhanced data integrity by adding constraints to prevent duplicate entries and enforce field size limits.

✏️ Tip: You can customize this high-level summary in your review settings.


🔄 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/netbirdio/netbird/pull/5182 **Author:** [@codingbot24-s](https://github.com/codingbot24-s) **Created:** 1/26/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/mysql-index-migration` --- ### 📝 Commits (1) - [`e648763`](https://github.com/netbirdio/netbird/commit/e6487637f799abbea256a46b2b24238459a5830d) Fix MySQL 8 migration failure on indexed string columns ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `management/server/peer/peer.go` (+1 -1) </details> ### 📄 Description ## Describe your changes This PR fixes a MySQL 8 / Aurora migration failure that occurs when upgrading NetBird from v0.62 to v0.63+. Older versions defined indexed string columns (e.g. Peer.Key) without explicit size constraints. During upgrades, GORM AutoMigrate attempts to convert these indexed VARCHAR columns into LONGTEXT, which MySQL does not allow without a key length, resulting in Error 1170 and management service startup failure. The fix explicitly defines a fixed VARCHAR size for indexed string fields to prevent GORM from converting them to TEXT/LONGTEXT during migrations. ## Issue ticket number and link Fixes #5171 https://github.com/netbirdio/netbird/issues/5171 ## Stack <!-- branch-stack --> ### Checklist - [X ] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [X ] Documentation is **not needed** for this change (explain why) This change only affects internal database migrations and does not introduce any user-facing configuration or behavioral changes. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/__ Reproduced using MySQL 8.0 by upgrading schema created with v0.62 to v0.64.0. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Enhanced data integrity by adding constraints to prevent duplicate entries and enforce field size limits. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 06:09:39 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#25188