I am using MySQL version 5.7.12; I am trying to add emoji support in a text field. I found this article. It states to alter the table and column to enable utf8mb4, which supports true unicode, including 4 byte unicode characters. I have a table comments and text field content, so I perform the following operation:
class ConvertCommentsToUtf8mb4 < ActiveRecord::Migration
# for each table that will store unicode execute:
execute "ALTER TABLE comments CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin"
# for each string/text column with unicode content execute:
execute "ALTER TABLE comments CHANGE content TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin"
When I try to run a migration, I get the following error:
Mysql2::Error: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to
use near 'SET utf8mb4 COLLATE utf8mb4_bin' at line 1: ALTER TABLE
comments CHANGE content TEXT CHARACTER SET utf8mb4 COLLATE
What might I be doing wrong?