前提・実現したいこと
Ec2,nginx,puma,Railsを使用してデプロイしています。
seed.rbのデータを反映させるために、ec2上でrake db:seed RAILS_ENV=productionを実行したところ文字列が数値で保存されてしまいます。
また、mysql内で直接データをINSERTしても同様の結果となってしまい困っています。
show variables like 'char%';の結果は以下です。
+--------------------------+-------------------------------------------+ | Variable_name | Value | +--------------------------+-------------------------------------------+ | character_set_client | utf8mb4 | | character_set_connection | utf8mb4 | | character_set_database | utf8mb4 | | character_set_filesystem | utf8mb4 | | character_set_results | utf8mb4 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | character_sets_dir | /rdsdbbin/mysql-5.7.22.R5/share/charsets/ | +--------------------------+-------------------------------------------+
どなたか原因わかりますでしょうか。
よろしくお願いします。
該当のソースコード
seed.rb
Prefecture.create( prefecture_name: '北海道' ) Prefecture.create( prefecture_name: '青森県' ) Prefecture.create( prefecture_name: '岩手県' ) ~ 省略 ~
結果
+----+-----------------+---------------------+---------------------+ | id | prefecture_name | created_at | updated_at | +----+-----------------+---------------------+---------------------+ | 1 | 1 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 2 | 2 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 3 | 3 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 4 | 4 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 5 | 5 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 6 | 6 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 7 | 7 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 8 | 8 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 9 | 9 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 10 | 10 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 11 | 11 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 12 | 12 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 13 | 13 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 14 | 14 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 15 | 19 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 16 | 20 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 17 | 15 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 18 | 16 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 19 | 17 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 20 | 18 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 21 | 21 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 22 | 22 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 23 | 23 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 24 | 24 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 25 | 25 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 26 | 26 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 27 | 27 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 28 | 28 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 29 | 29 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 30 | 30 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 31 | 31 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 32 | 32 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 33 | 33 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 34 | 34 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 35 | 35 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 36 | 36 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 37 | 37 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 38 | 38 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 39 | 39 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 40 | 40 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 41 | 41 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 42 | 42 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 43 | 43 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 44 | 44 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 45 | 45 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 46 | 46 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | | 47 | 47 | 2021-01-12 13:42:11 | 2021-01-12 13:42:11 | +----+-----------------+---------------------+---------------------+
INSERT INTO prefectures (id, prefecture_name) VALUES(48,'テスト');
で直接INSERTした結果は以下です。
48 | 0 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00
回答1件
あなたの回答
tips
プレビュー