forked from fleetdm/fleet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for MySQL 8.4.2 (fleetdm#21364)
fleetdm#21270 The main change for MySQL 8.4.2 is that foreign key constraints are stricter: https://dev.mysql.com/doc/refman/8.4/en/server-system-variables.html#sysvar_restrict_fk_on_non_standard_key Also, most replica-related commands have been renamed. # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Added/updated tests - [x] If database migrations are included, checked table schema to confirm autoupdate - [x] Manual QA for all new/changed functionality
- Loading branch information
Showing
11 changed files
with
143 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added support for MySQL 8.4.2 LTS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
server/datastore/mysql/migrations/tables/20240816103247_AddIndexToNanoUsers.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package tables | ||
|
||
import ( | ||
"database/sql" | ||
"fmt" | ||
) | ||
|
||
func init() { | ||
MigrationClient.AddMigration(Up_20240816103247, Down_20240816103247) | ||
} | ||
|
||
func Up_20240816103247(tx *sql.Tx) error { | ||
|
||
// This constraint is required for MySQL 8.4.2 because nano_enrollments foreign key expects nano_users.id to be unique. | ||
if !indexExistsTx(tx, "nano_users", "idx_unique_id") { | ||
_, err := tx.Exec(`ALTER TABLE nano_users ADD CONSTRAINT idx_unique_id UNIQUE (id)`) | ||
if err != nil { | ||
return fmt.Errorf("adding unique index to nano_users: %w", err) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func Down_20240816103247(tx *sql.Tx) error { | ||
return nil | ||
} |
26 changes: 26 additions & 0 deletions
26
server/datastore/mysql/migrations/tables/20240816103247_AddIndexToNanoUsers_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package tables | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestUp_20240816103247(t *testing.T) { | ||
db := applyUpToPrev(t) | ||
|
||
// Apply current migration | ||
applyNext(t, db) | ||
|
||
// Check if the index exists | ||
var indexExists bool | ||
err := db.QueryRow(` | ||
SELECT 1 FROM information_schema.statistics | ||
WHERE table_schema = DATABASE() | ||
AND table_name = 'nano_users' | ||
AND index_name = 'idx_unique_id' | ||
`).Scan(&indexExists) | ||
|
||
require.NoError(t, err) | ||
require.True(t, indexExists, "Index idx_unique_id should exist") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters