diff --git a/lib/postal/message_db/mysql.rb b/lib/postal/message_db/mysql.rb index 3792437..2ef81d2 100644 --- a/lib/postal/message_db/mysql.rb +++ b/lib/postal/message_db/mysql.rb @@ -7,7 +7,7 @@ module Postal # it would be undesirable as we'd just end up with lots of connections. def self.new_client - Mysql2::Client.new(:host => Postal.config.message_db.host, :username => Postal.config.message_db.username, :password => Postal.config.message_db.password, :port => Postal.config.message_db.port, :reconnect => true) + Mysql2::Client.new(:host => Postal.config.message_db.host, :username => Postal.config.message_db.username, :password => Postal.config.message_db.password, :port => Postal.config.message_db.port, :reconnect => true, :encoding => Postal.config.message_db.encoding || 'utf8mb4') end @free_clients = [] diff --git a/lib/postal/message_db/provisioner.rb b/lib/postal/message_db/provisioner.rb index 5abf79f..6680fe0 100644 --- a/lib/postal/message_db/provisioner.rb +++ b/lib/postal/message_db/provisioner.rb @@ -33,7 +33,7 @@ module Postal # Creates a new empty database # def create - @database.query("CREATE DATABASE `#{@database.database_name}` CHARSET utf8 COLLATE UTF8_UNICODE_CI;") + @database.query("CREATE DATABASE `#{@database.database_name}` CHARSET utf8mb4 COLLATE utf8mb4_bin;") true rescue Mysql2::Error => e e.message =~ /database exists/ ? false : raise @@ -185,7 +185,7 @@ module Postal s << ", PRIMARY KEY (`id`)" end - s << ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;" + s << ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;" end end