Skip to content

Commit

Permalink
Follow the default collation of Rails rather than MySQL.
Browse files Browse the repository at this point in the history
`utf8*_general_ci` is known to be problematic in some languages like
Japanese, but hopefully it wouldn't do harm in practice in our case.
  • Loading branch information
knu committed Aug 21, 2014
1 parent ba0009b commit f4f6930
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions db/migrate/20140813110107_set_charset_for_mysql.rb
Expand Up @@ -40,10 +40,10 @@ def change

case type
when :string, :text
options.update(charset: 'utf8', collation: 'utf8_general_ci')
options.update(charset: 'utf8', collation: 'utf8_unicode_ci')
case name
when 'username'
options.update(limit: 767 / 4, charset: 'utf8mb4', collation: 'utf8mb4_general_ci')
options.update(limit: 767 / 4, charset: 'utf8mb4', collation: 'utf8mb4_unicode_ci')
when 'message', 'options', 'name', 'memory',
'handler', 'last_error', 'payload', 'description'
options.update(charset: 'utf8mb4', collation: 'utf8mb4_bin')
Expand All @@ -60,10 +60,10 @@ def change
change_column table_name, name, type, options
}

execute 'ALTER TABLE %s CHARACTER SET utf8 COLLATE utf8_general_ci' % table_name
execute 'ALTER TABLE %s CHARACTER SET utf8 COLLATE utf8_unicode_ci' % table_name
}

execute 'ALTER DATABASE %s CHARACTER SET utf8 COLLATE utf8_general_ci' % conn.current_database
execute 'ALTER DATABASE %s CHARACTER SET utf8 COLLATE utf8_unicode_ci' % conn.current_database
end

dir.down do
Expand Down
2 changes: 1 addition & 1 deletion db/schema.rb
Expand Up @@ -143,7 +143,7 @@
t.integer "failed_attempts", default: 0
t.string "unlock_token"
t.datetime "locked_at"
t.string "username", limit: 191, null: false, charset: "utf8mb4", collation: "utf8mb4_general_ci"
t.string "username", limit: 191, null: false, charset: "utf8mb4", collation: "utf8mb4_unicode_ci"
t.string "invitation_code", null: false, collation: "utf8_bin"
t.integer "scenario_count", default: 0, null: false
end
Expand Down

0 comments on commit f4f6930

Please sign in to comment.