Fix missing collation in database migration (#18146)

This commit is contained in:
Martin Angers 2024-04-09 13:53:53 -04:00 committed by GitHub
commit 2da35b6a38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View file

@ -9,10 +9,11 @@ If some of the following don't apply, delete the relevant line.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to confirm autoupdate
- [ ] If database migrations are included, checked table schema to confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows and Linux.

View file

@ -0,0 +1 @@
* Fixed an issue with the `20240327115617_CreateTableNanoDDMRequests` database migration where it could fail if the database did not default to the `utf8mb4_unicode_ci` collation.

View file

@ -14,9 +14,9 @@ func Up_20240327115617(tx *sql.Tx) error {
CREATE TABLE mdm_apple_declarative_requests (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
enrollment_id VARCHAR(255) NOT NULL,
enrollment_id VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL,
-- Should be one of "tokens", "declaration-items", "status", or "declaration/…/…" where the ellipses reference a declaration on the server
message_type VARCHAR(255) NOT NULL,
message_type VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL,
-- json payload
raw_json TEXT,
PRIMARY KEY (id),