Fix collation inconsistency on saved_filters/ticket_attachments (#41)
README Dev Note #12 mandates utf8mb4_general_ci for new tables, but these two tables were created with utf8mb4_unicode_ci in the baseline schema — inconsistent with every other table, and a future join or comparison against a general_ci column would need explicit COLLATE casts or hit "Illegal mix of collations" errors. - Fixed 000_baseline.sql so a fresh install matches the convention directly. - Added 002_fix_collation_consistency.sql for existing deployments. MariaDB silently drops the inline CHECK (json_valid(...)) constraint on saved_filters.filter_criteria when that column is MODIFYed (found by actually running this against a local MariaDB instance), so the migration explicitly re-adds it after the collation conversion. Verified against a local MariaDB 10.11: baseline applies cleanly, migration is idempotent (safe to run twice), and the json_valid CHECK is still enforced afterward. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MGDKHiU5RJdo3dqQUDow3X
This commit is contained in:
@@ -155,7 +155,7 @@ CREATE TABLE IF NOT EXISTS `saved_filters` (
|
||||
UNIQUE KEY `unique_user_filter_name` (`user_id`,`filter_name`),
|
||||
KEY `idx_user_filters` (`user_id`,`is_default`),
|
||||
CONSTRAINT `saved_filters_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
-- ============ status_transitions ============
|
||||
CREATE TABLE IF NOT EXISTS `status_transitions` (
|
||||
@@ -185,7 +185,7 @@ CREATE TABLE IF NOT EXISTS `ticket_attachments` (
|
||||
KEY `idx_attachments_ticket` (`ticket_id`),
|
||||
KEY `idx_attachments_uploaded_by` (`uploaded_by`),
|
||||
CONSTRAINT `ticket_attachments_ibfk_1` FOREIGN KEY (`uploaded_by`) REFERENCES `users` (`user_id`) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
-- ============ ticket_comments ============
|
||||
CREATE TABLE IF NOT EXISTS `ticket_comments` (
|
||||
|
||||
Reference in New Issue
Block a user