Skip to content

Commit

Permalink
Fix various issues with MySQL
Browse files Browse the repository at this point in the history
* Updated the mysql2 gem so you can use newer MySQL / MariaDB versions
* Changed the encoding to utf8mb4 to fix astral Unicode
* DB.database_type seems to be just mysql
  • Loading branch information
Dorian Stoll committed Mar 1, 2017
1 parent 36caad0 commit 05ee0e6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Expand Up @@ -12,7 +12,7 @@ GEM
tilt
hiredis (0.5.2)
multi_json (1.10.1)
mysql2 (0.3.16)
mysql2 (0.4.4)
pg (0.18.4)
rack (1.5.2)
rack-protection (1.5.3)
Expand Down
2 changes: 1 addition & 1 deletion config/sql/mysql-schema.sql
Expand Up @@ -9,7 +9,7 @@ CREATE TABLE `irclog` (
oper_nick VARCHAR(40),
payload TEXT,
PRIMARY KEY(`id`)
) CHARSET=utf8 ENGINE=MyISAM;
) CHARSET=utf8mb4 ENGINE=MyISAM;

CREATE INDEX `irclog_channel_timestamp_index` ON `irclog` (channel, timestamp);
CREATE INDEX `irclog_channel_opcode_index` ON `irclog` (channel, opcode);
Expand Down
2 changes: 1 addition & 1 deletion lib/irclogger.rb
Expand Up @@ -3,7 +3,7 @@
require 'sequel'

Config = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'config', 'application.yml'))
DB = Sequel.connect(Config['database'])
DB = Sequel.connect(Config['database'], :encoding => 'utf8mb4')

require 'irclogger/message'
require 'irclogger/channel'
2 changes: 1 addition & 1 deletion lib/irclogger/viewer.rb
Expand Up @@ -21,7 +21,7 @@ class Viewer < Sinatra::Base

before do
case DB.database_type
when :mysql2
when :mysql
@channels = DB["select channel from irclog group by channel"].map { |r| r[:channel] }
when :postgres
# https://wiki.postgresql.org/wiki/Loose_indexscan
Expand Down

0 comments on commit 05ee0e6

Please sign in to comment.