Change the adapter encoding to utf8mb4
This commit is contained in:
parent
63eca447d0
commit
b0ef4509a6
3 changed files with 44 additions and 5 deletions
|
|
@ -5,7 +5,7 @@ mysql: &mysql
|
|||
username: "root"
|
||||
password: ""
|
||||
# socket: /tmp/mysql.sock
|
||||
charset: utf8
|
||||
charset: utf8mb4
|
||||
collation: utf8_bin
|
||||
|
||||
postgres: &postgres
|
||||
|
|
@ -25,7 +25,7 @@ common: &common
|
|||
|
||||
# Should match environment.sidekiq.concurrency
|
||||
#pool: 25
|
||||
|
||||
|
||||
##################################################
|
||||
#### CONFIGURE ABOVE #############################
|
||||
##################################################
|
||||
|
|
|
|||
38
db/migrate/20150106050733_set_mysql_to_unicode_mb4.rb
Normal file
38
db/migrate/20150106050733_set_mysql_to_unicode_mb4.rb
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
class SetMysqlToUnicodeMb4 < ActiveRecord::Migration
|
||||
|
||||
UTF8_PAIRS = {
|
||||
'comments': 'text',
|
||||
'messages': 'text',
|
||||
'poll_answers': 'answer',
|
||||
'polls': 'question',
|
||||
'posts': 'text',
|
||||
}
|
||||
|
||||
def self.up
|
||||
if ENV['DB'] == 'mysql'
|
||||
execute "ALTER DATABASE `#{ActiveRecord::Base.connection.current_database}` CHARACTER SET utf8mb4;"
|
||||
|
||||
ActiveRecord::Base.connection.tables.each do |table|
|
||||
execute "ALTER TABLE `#{table}` CHARACTER SET = utf8mb4;"
|
||||
end
|
||||
|
||||
UTF8_PAIRS.each do |table, col|
|
||||
execute "ALTER TABLE `#{table}` CHANGE `#{col}` `#{col}` TEXT CHARACTER SET utf8mb4 NULL;"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
if ENV['DB'] == 'mysql'
|
||||
execute "ALTER DATABASE `#{ActiveRecord::Base.connection.current_database}` CHARACTER SET utf8;"
|
||||
|
||||
ActiveRecord::Base.connection.tables.each do |table|
|
||||
execute "ALTER TABLE `#{table}` CHARACTER SET = utf8;"
|
||||
end
|
||||
|
||||
UTF8_PAIRS.each do |table, col|
|
||||
execute "ALTER TABLE `#{table}` CHANGE `#{col}` `#{col}` TEXT CHARACTER SET utf8 NULL;"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20141230214830) do
|
||||
ActiveRecord::Schema.define(version: 20150106050733) do
|
||||
|
||||
create_table "account_deletions", force: true do |t|
|
||||
t.string "diaspora_handle"
|
||||
|
|
@ -66,6 +66,7 @@ ActiveRecord::Schema.define(version: 20141230214830) do
|
|||
t.string "name"
|
||||
t.string "ask", limit: 128
|
||||
t.string "subscription", limit: 128, null: false
|
||||
t.text "groups"
|
||||
end
|
||||
|
||||
add_index "chat_contacts", ["user_id", "jid"], name: "index_chat_contacts_on_user_id_and_jid", unique: true, using: :btree
|
||||
|
|
@ -241,7 +242,7 @@ ActiveRecord::Schema.define(version: 20141230214830) do
|
|||
t.text "data", null: false
|
||||
end
|
||||
|
||||
add_index "o_embed_caches", ["url"], name: "index_o_embed_caches_on_url", length: {"url"=>255}, using: :btree
|
||||
add_index "o_embed_caches", ["url"], name: "index_o_embed_caches_on_url", using: :btree
|
||||
|
||||
create_table "open_graph_caches", force: true do |t|
|
||||
t.string "title"
|
||||
|
|
@ -429,11 +430,11 @@ ActiveRecord::Schema.define(version: 20141230214830) do
|
|||
|
||||
create_table "reports", force: true do |t|
|
||||
t.integer "item_id", null: false
|
||||
t.string "item_type", null: false
|
||||
t.boolean "reviewed", default: false
|
||||
t.text "text"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "item_type", null: false
|
||||
t.integer "user_id", null: false
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue