如何解决运行 rails 迁移会覆盖我的字符集知道为什么吗?
MysqL> show variables like "%character%";show variables like "%collation%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/MysqL/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
+----------------------+--------------------+
| Variable_name | Value |
+----------------------+--------------------+
| collation_connection | utf8mb4_general_ci |
| collation_database | utf8mb4_general_ci |
| collation_server | utf8mb4_general_ci |
+----------------------+--------------------+```
我的 database.yml [我在创建之后添加了编码/归类]。但是我确实将所有表和数据库更新为 utf8mb4。
development:
adapter: MysqL2
encoding: utf8mb4
collation: utf8mb4_general_ci
当我运行任何 rails db:migrate
命令时,每个表的导出总是如下所示:
-/*!50503 SET character_set_client = utf8mb4 */;
+/*!40101 SET character_set_client = utf8 */;
我可以检查这些单独的表中的任何一个,并看到它们确实是 utf8mb4(但仅限于某些行。也许这是一个问题?):
MysqL> show full columns from ab_experiment_buckets;
+--------------------+--------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+--------------------+--------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
| id | int(11) | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | |
| foobar_id | int(11) | NULL | NO | | NULL | | select,references | |
| foobar_nam | varchar(255) | utf8mb4_general_ci | NO | | NULL | | select,references | |
| foobar_index | int(11) | NULL | NO | | NULL | | select,references | |
| foobar_probability | float | NULL | NO | | NULL | | select,references | |
| foobar_value | text | utf8mb4_general_ci | YES | | NULL | | select,references | |
| created_at | datetime | NULL | YES | | NULL | | select,references | |
| updated_at | datetime | NULL | YES | | NULL | | select,references | |
| foobar_is_default | tinyint(1) | NULL | YES | | NULL | | select,references | |
+--------------------+--------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。