back out 9ece666
removing utf8mb4 hacks, no longer needed
This commit is contained in:
parent
bdc1f36360
commit
c9571dabaf
4
Gemfile
4
Gemfile
|
@ -2,10 +2,12 @@ source "https://rubygems.org"
|
|||
|
||||
gem "rails", "3.2.13"
|
||||
|
||||
gem "rake", "10.0.3"
|
||||
|
||||
# Bundle edge Rails instead:
|
||||
# gem "rails", :git => "git://github.com/rails/rails.git"
|
||||
|
||||
gem "mysql2"
|
||||
gem "mysql2", :git => "git://github.com/brianmario/mysql2.git"
|
||||
|
||||
gem "jquery-rails"
|
||||
|
||||
|
|
10
Gemfile.lock
10
Gemfile.lock
|
@ -1,3 +1,9 @@
|
|||
GIT
|
||||
remote: git://github.com/brianmario/mysql2.git
|
||||
revision: 5ebf34171d30048ef1cc641120208b134ea401bd
|
||||
specs:
|
||||
mysql2 (0.3.12b6)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
|
@ -54,7 +60,6 @@ GEM
|
|||
treetop (~> 1.4.8)
|
||||
mime-types (1.21)
|
||||
multi_json (1.7.1)
|
||||
mysql2 (0.3.11)
|
||||
nokogiri (1.5.6)
|
||||
polyglot (0.3.3)
|
||||
rack (1.4.5)
|
||||
|
@ -130,9 +135,10 @@ DEPENDENCIES
|
|||
htmlentities
|
||||
jquery-rails
|
||||
machinist
|
||||
mysql2
|
||||
mysql2!
|
||||
nokogiri
|
||||
rails (= 3.2.13)
|
||||
rake (= 10.0.3)
|
||||
rdiscount
|
||||
rspec-rails (~> 2.6)
|
||||
sqlite3
|
||||
|
|
|
@ -267,8 +267,7 @@ class Comment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def comment=(com)
|
||||
# TODO: remove remove_mb4 hack
|
||||
self[:comment] = com.to_s.rstrip.remove_mb4
|
||||
self[:comment] = com.to_s.rstrip
|
||||
self.markeddown_comment = self.generated_markeddown_comment
|
||||
end
|
||||
|
||||
|
|
|
@ -67,16 +67,6 @@ class Message < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# TODO: remove remove_mb4 hack
|
||||
def body=(b)
|
||||
self[:body] = b.to_s.remove_mb4
|
||||
end
|
||||
|
||||
# TODO: remove remove_mb4 hack
|
||||
def subject=(s)
|
||||
self[:subject] = s.to_s.remove_mb4
|
||||
end
|
||||
|
||||
def linkified_body
|
||||
Markdowner.to_html(self.body)
|
||||
end
|
||||
|
|
|
@ -271,8 +271,7 @@ class Story < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def description=(desc)
|
||||
# TODO: remove remove_mb4 hack
|
||||
self[:description] = desc.to_s.remove_mb4.rstrip
|
||||
self[:description] = desc.to_s.rstrip
|
||||
self.markeddown_description = self.generated_markeddown_description
|
||||
end
|
||||
|
||||
|
@ -316,8 +315,7 @@ class Story < ActiveRecord::Base
|
|||
|
||||
def title=(t)
|
||||
# change unicode whitespace characters into real spaces
|
||||
# TODO: remove remove_mb4 hack
|
||||
self[:title] = t.strip.remove_mb4
|
||||
self[:title] = t.strip
|
||||
end
|
||||
|
||||
def title_as_url
|
||||
|
|
10
db/migrate/20130526164230_change_tables_to_utf8mb4.rb
Normal file
10
db/migrate/20130526164230_change_tables_to_utf8mb4.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class ChangeTablesToUtf8mb4 < ActiveRecord::Migration
|
||||
def up
|
||||
[ "comments", "invitations", "messages", "moderations", "stories", "users" ].each do |t|
|
||||
execute("alter table #{t} convert to character set utf8mb4")
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
90
db/schema.rb
90
db/schema.rb
|
@ -11,23 +11,23 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20121112165212) do
|
||||
ActiveRecord::Schema.define(:version => 20130526164230) do
|
||||
|
||||
create_table "comments", :force => true do |t|
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at"
|
||||
t.string "short_id", :limit => 10, :default => "", :null => false
|
||||
t.integer "story_id", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
t.string "short_id", :limit => 10, :default => "", :null => false
|
||||
t.integer "story_id", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
t.integer "parent_comment_id"
|
||||
t.integer "thread_id"
|
||||
t.text "comment", :limit => 2147483647, :null => false
|
||||
t.integer "upvotes", :default => 0, :null => false
|
||||
t.integer "downvotes", :default => 0, :null => false
|
||||
t.decimal "confidence", :precision => 20, :scale => 19, :default => 0.0, :null => false
|
||||
t.text "markeddown_comment", :limit => 2147483647
|
||||
t.boolean "is_deleted", :default => false
|
||||
t.boolean "is_moderated", :default => false
|
||||
t.text "comment", :limit => 16777215, :null => false
|
||||
t.integer "upvotes", :default => 0, :null => false
|
||||
t.integer "downvotes", :default => 0, :null => false
|
||||
t.decimal "confidence", :precision => 20, :scale => 19, :default => 0.0, :null => false
|
||||
t.text "markeddown_comment", :limit => 16777215
|
||||
t.boolean "is_deleted", :default => false
|
||||
t.boolean "is_moderated", :default => false
|
||||
end
|
||||
|
||||
add_index "comments", ["confidence"], :name => "confidence_idx"
|
||||
|
@ -39,9 +39,9 @@ ActiveRecord::Schema.define(:version => 20121112165212) do
|
|||
t.integer "user_id"
|
||||
t.string "email"
|
||||
t.string "code"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.text "memo"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.text "memo", :limit => 16777215
|
||||
end
|
||||
|
||||
create_table "keystores", :id => false, :force => true do |t|
|
||||
|
@ -55,45 +55,45 @@ ActiveRecord::Schema.define(:version => 20121112165212) do
|
|||
t.datetime "created_at"
|
||||
t.integer "author_user_id"
|
||||
t.integer "recipient_user_id"
|
||||
t.boolean "has_been_read", :default => false
|
||||
t.boolean "has_been_read", :default => false
|
||||
t.string "subject", :limit => 100
|
||||
t.text "body"
|
||||
t.text "body", :limit => 16777215
|
||||
t.string "short_id", :limit => 30
|
||||
t.boolean "deleted_by_author", :default => false
|
||||
t.boolean "deleted_by_recipient", :default => false
|
||||
t.boolean "deleted_by_author", :default => false
|
||||
t.boolean "deleted_by_recipient", :default => false
|
||||
end
|
||||
|
||||
add_index "messages", ["short_id"], :name => "random_hash", :unique => true
|
||||
|
||||
create_table "moderations", :force => true do |t|
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "moderator_user_id"
|
||||
t.integer "story_id"
|
||||
t.integer "comment_id"
|
||||
t.integer "user_id"
|
||||
t.text "action"
|
||||
t.text "reason"
|
||||
t.text "action", :limit => 16777215
|
||||
t.text "reason", :limit => 16777215
|
||||
end
|
||||
|
||||
create_table "stories", :force => true do |t|
|
||||
t.datetime "created_at"
|
||||
t.integer "user_id"
|
||||
t.string "url", :limit => 250, :default => ""
|
||||
t.string "title", :limit => 150, :default => "", :null => false
|
||||
t.text "description"
|
||||
t.string "short_id", :limit => 6, :default => "", :null => false
|
||||
t.integer "is_expired", :limit => 1, :default => 0, :null => false
|
||||
t.integer "upvotes", :default => 0, :null => false
|
||||
t.integer "downvotes", :default => 0, :null => false
|
||||
t.integer "is_moderated", :limit => 1, :default => 0, :null => false
|
||||
t.decimal "hotness", :precision => 20, :scale => 10, :default => 0.0, :null => false
|
||||
t.text "markeddown_description"
|
||||
t.string "url", :limit => 250, :default => ""
|
||||
t.string "title", :limit => 150, :default => "", :null => false
|
||||
t.text "description", :limit => 16777215
|
||||
t.string "short_id", :limit => 6, :default => "", :null => false
|
||||
t.integer "is_expired", :limit => 1, :default => 0, :null => false
|
||||
t.integer "upvotes", :default => 0, :null => false
|
||||
t.integer "downvotes", :default => 0, :null => false
|
||||
t.integer "is_moderated", :limit => 1, :default => 0, :null => false
|
||||
t.decimal "hotness", :precision => 20, :scale => 10, :default => 0.0, :null => false
|
||||
t.text "markeddown_description", :limit => 16777215
|
||||
end
|
||||
|
||||
add_index "stories", ["hotness"], :name => "hotness_idx"
|
||||
add_index "stories", ["is_expired", "is_moderated"], :name => "is_idxes"
|
||||
add_index "stories", ["url"], :name => "url"
|
||||
add_index "stories", ["url"], :name => "url", :length => {"url"=>191}
|
||||
|
||||
create_table "tag_filters", :force => true do |t|
|
||||
t.datetime "created_at", :null => false
|
||||
|
@ -126,21 +126,21 @@ ActiveRecord::Schema.define(:version => 20121112165212) do
|
|||
t.string "email", :limit => 100
|
||||
t.string "password_digest", :limit => 75
|
||||
t.datetime "created_at"
|
||||
t.integer "email_notifications", :limit => 1, :default => 0
|
||||
t.integer "is_admin", :limit => 1, :default => 0, :null => false
|
||||
t.boolean "email_notifications", :default => false
|
||||
t.boolean "is_admin", :default => false
|
||||
t.string "password_reset_token", :limit => 75
|
||||
t.string "session_token", :limit => 75, :default => "", :null => false
|
||||
t.text "about"
|
||||
t.string "session_token", :limit => 75, :default => "", :null => false
|
||||
t.text "about", :limit => 16777215
|
||||
t.integer "invited_by_user_id"
|
||||
t.boolean "email_replies", :default => false
|
||||
t.boolean "pushover_replies", :default => false
|
||||
t.boolean "email_replies", :default => false
|
||||
t.boolean "pushover_replies", :default => false
|
||||
t.string "pushover_user_key"
|
||||
t.string "pushover_device"
|
||||
t.boolean "email_messages", :default => true
|
||||
t.boolean "pushover_messages", :default => true
|
||||
t.boolean "is_moderator", :default => false
|
||||
t.boolean "email_mentions", :default => false
|
||||
t.boolean "pushover_mentions", :default => false
|
||||
t.boolean "email_messages", :default => true
|
||||
t.boolean "pushover_messages", :default => true
|
||||
t.boolean "is_moderator", :default => false
|
||||
t.boolean "email_mentions", :default => false
|
||||
t.boolean "pushover_mentions", :default => false
|
||||
t.string "rss_token"
|
||||
end
|
||||
|
||||
|
|
|
@ -9,22 +9,3 @@ module ActiveRecord
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
# XXX stupid hack to strip out utf8mb4 chars that may break mysql queries
|
||||
# TODO upgrade to mysql 5.5, convert tables to utf8mb4, upgrade mysql2 gem when
|
||||
# it supports utf8mb4, and remove this hack
|
||||
class String
|
||||
def remove_mb4
|
||||
t = "".force_encoding(self.encoding)
|
||||
|
||||
self.each_char do |c|
|
||||
if c.bytesize == 4
|
||||
t << " "
|
||||
else
|
||||
t << c
|
||||
end
|
||||
end
|
||||
|
||||
t
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue