-- Fixes a real bug in the two migrations above: they were created with
-- `latin1` charset (matching this database's older, pre-existing tables),
-- but latin1 can only store single-byte characters and CANNOT hold emoji
-- (most emoji are 4-byte UTF-8 characters). Any section icon, or any
-- comment/caption containing an emoji, would get silently corrupted or
-- dropped on save -- this is why section icons stopped showing up.
--
-- Only run this if you already ran 2026_09_13_add_mod_dynamic_fields.sql
-- and/or 2026_09_13_add_mod_observations.sql BEFORE this fix -- if you're
-- running the migrations fresh, they already create the tables correctly
-- and this file has nothing to do (the ALTERs below are harmless no-ops
-- on a table that's already utf8mb4, but there's no need to run it).
--
-- IMPORTANT: this prevents FUTURE corruption, but cannot recover data that
-- was already mangled by the latin1 bug -- any section icon that isn't
-- displaying correctly after this runs will need to be re-entered once
-- (Manage Fields -> re-save the section). New entries going forward will
-- be unaffected.

ALTER TABLE `mod_field_sections` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `mod_fields` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `mod_report_values` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `mod_report_observations` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `mod_observation_images` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
