Add warning about encoding change

Add warning about MySQL collation

Fix database index length

This allows new databases to be created with utf8mb4, on MySQL. The maximum
column size is 767 bytes. Each character is 4 bytes long -> 767 / 4 = 191
characters for the column.
This commit is contained in:
Dumitru Ursu 2015-01-06 14:45:46 +02:00
parent b0ef4509a6
commit dda5f71124
9 changed files with 42 additions and 34 deletions

View file

@ -32,6 +32,10 @@ series and run our comprehensive test suite against it.
## Change in defaults.yml ## Change in defaults.yml
The default for including jQuery from a CDN has changed. If you want to continue to include it from a CDN, please explicitly set the `jquery_cdn` setting to `true` in diaspora.yml. The default for including jQuery from a CDN has changed. If you want to continue to include it from a CDN, please explicitly set the `jquery_cdn` setting to `true` in diaspora.yml.
## Change in database.yml
For MySQL databases, replace `charset: utf8` with `encoding: utf8mb4`. This is enables full UTF8 support (4bytes characters), including standard emoji characters. See `database.yml.example` for reference.
Also, do not forget to remove `collation: utf8_bin`. It will choose a compatible one automatically.
## Experimental chat feature ## Experimental chat feature
This release adds experimental integration with XMPP for real-time chat. Please see [our wiki](https://wiki.diasporafoundation.org/Vines) for further informations. This release adds experimental integration with XMPP for real-time chat. Please see [our wiki](https://wiki.diasporafoundation.org/Vines) for further informations.

View file

@ -5,8 +5,7 @@ mysql: &mysql
username: "root" username: "root"
password: "" password: ""
# socket: /tmp/mysql.sock # socket: /tmp/mysql.sock
charset: utf8mb4 encoding: utf8mb4
collation: utf8_bin
postgres: &postgres postgres: &postgres
adapter: postgresql adapter: postgresql

View file

@ -199,7 +199,7 @@ class CreateSchema < ActiveRecord::Migration
t.text "data", :null => false t.text "data", :null => false
end end
add_index "o_embed_caches", ["url"], :name => "index_o_embed_caches_on_url", :length => {"url"=>255} add_index "o_embed_caches", ["url"], :name => "index_o_embed_caches_on_url", :length => {"url"=> 191}, using: :btree
create_table "participations", :force => true do |t| create_table "participations", :force => true do |t|
t.string "guid" t.string "guid"
@ -227,7 +227,7 @@ class CreateSchema < ActiveRecord::Migration
t.integer "fetch_status", :default => 0 t.integer "fetch_status", :default => 0
end end
add_index "people", ["diaspora_handle"], :name => "index_people_on_diaspora_handle", :unique => true add_index "people", ["diaspora_handle"], :name => "index_people_on_diaspora_handle", :unique => true, :length => {"diaspora_handle" => 191}
add_index "people", ["guid"], :name => "index_people_on_guid", :unique => true add_index "people", ["guid"], :name => "index_people_on_guid", :unique => true
add_index "people", ["owner_id"], :name => "index_people_on_owner_id", :unique => true add_index "people", ["owner_id"], :name => "index_people_on_owner_id", :unique => true
@ -265,7 +265,7 @@ class CreateSchema < ActiveRecord::Migration
t.integer "author_id", :null => false t.integer "author_id", :null => false
t.boolean "public", :default => false, :null => false t.boolean "public", :default => false, :null => false
t.string "diaspora_handle" t.string "diaspora_handle"
t.string "guid", :null => false t.string "guid"
t.boolean "pending", :default => false, :null => false t.boolean "pending", :default => false, :null => false
t.string "type", :limit => 40, :null => false t.string "type", :limit => 40, :null => false
t.text "text" t.text "text"
@ -337,7 +337,7 @@ class CreateSchema < ActiveRecord::Migration
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
add_index "rails_admin_histories", ["item", "table", "month", "year"], :name => "index_rails_admin_histories" add_index "rails_admin_histories", ["item", "table", "month", "year"], :name => "index_rails_admin_histories", :length => {"table" => 180}
create_table "roles", :force => true do |t| create_table "roles", :force => true do |t|
t.integer "person_id" t.integer "person_id"
@ -404,7 +404,7 @@ class CreateSchema < ActiveRecord::Migration
t.string "name" t.string "name"
end end
add_index "tags", ["name"], :name => "index_tags_on_name", :unique => true add_index "tags", ["name"], :name => "index_tags_on_name", :unique => true, :length => {"name" => 191}
create_table "user_preferences", :force => true do |t| create_table "user_preferences", :force => true do |t|
t.string "email_type" t.string "email_type"
@ -449,7 +449,7 @@ class CreateSchema < ActiveRecord::Migration
end end
add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true
add_index "users", ["email"], :name => "index_users_on_email" add_index "users", ["email"], :name => "index_users_on_email", length: {"email" => "191"}
add_index "users", ["invitation_service", "invitation_identifier"], :name => "index_users_on_invitation_service_and_invitation_identifier", :unique => true add_index "users", ["invitation_service", "invitation_identifier"], :name => "index_users_on_invitation_service_and_invitation_identifier", :unique => true
add_index "users", ["invitation_token"], :name => "index_users_on_invitation_token" add_index "users", ["invitation_token"], :name => "index_users_on_invitation_token"
add_index "users", ["username"], :name => "index_users_on_username", :unique => true add_index "users", ["username"], :name => "index_users_on_username", :unique => true

View file

@ -1,6 +1,6 @@
class AddTweetIdToPost < ActiveRecord::Migration class AddTweetIdToPost < ActiveRecord::Migration
def change def change
add_column :posts, :tweet_id, :string add_column :posts, :tweet_id, :string, limit: 64
add_index :posts, :tweet_id add_index :posts, :tweet_id
end end
end end

View file

@ -1,9 +1,9 @@
class RemoveLimitFromRootGuidInPosts < ActiveRecord::Migration class RemoveLimitFromRootGuidInPosts < ActiveRecord::Migration
def up def up
change_column :posts, :root_guid, :string change_column :posts, :root_guid, :string, limit: 64
end end
def down def down
change_column :posts, :root_guid, :string, limit: 30 change_column :posts, :root_guid, :string, limit: 64
end end
end end

View file

@ -1,13 +1,14 @@
class CreateChatContacts < ActiveRecord::Migration class CreateChatContacts < ActiveRecord::Migration
def up def up
create_table :chat_contacts do |t| create_table :chat_contacts do |t|
t.integer :user_id, null: false t.integer :user_id, null: false
t.string :jid, null: false ## JID <= 3071 bytes http://tools.ietf.org/html/rfc6122
t.string :name, limit: 255, null: true t.string :jid, limit: 3071, null: false
t.string :ask, limit: 128, null: true t.string :name, limit: 255, null: true
t.string :subscription, limit: 128, null: false t.string :ask, limit: 128, null: true
t.string :subscription, limit: 128, null: false
end end
add_index :chat_contacts, [:user_id, :jid], unique: true add_index :chat_contacts, [:user_id, :jid], unique: true, length: {"jid": 100}
end end
def down def down

View file

@ -1,18 +1,20 @@
class SetMysqlToUnicodeMb4 < ActiveRecord::Migration class SetMysqlToUnicodeMb4 < ActiveRecord::Migration
UTF8_PAIRS = { UTF8_PAIRS = {}
'comments': 'text', tables = ActiveRecord::Base.connection.tables
'messages': 'text',
'poll_answers': 'answer', tables.each do |table|
'polls': 'question', ActiveRecord::Base.connection.columns(table).each do |column|
'posts': 'text', # build a hash with all the columns that contain text
} UTF8_PAIRS[table] = column.name if (column.type == :string) || (column.type == :text)
end
end
def self.up def self.up
if ENV['DB'] == 'mysql' if AppConfig.mysql?
execute "ALTER DATABASE `#{ActiveRecord::Base.connection.current_database}` CHARACTER SET utf8mb4;" execute "ALTER DATABASE `#{ActiveRecord::Base.connection.current_database}` CHARACTER SET utf8mb4;"
ActiveRecord::Base.connection.tables.each do |table| tables.each do |table|
execute "ALTER TABLE `#{table}` CHARACTER SET = utf8mb4;" execute "ALTER TABLE `#{table}` CHARACTER SET = utf8mb4;"
end end
@ -23,10 +25,10 @@ class SetMysqlToUnicodeMb4 < ActiveRecord::Migration
end end
def self.down def self.down
if ENV['DB'] == 'mysql' if AppConfig.mysql?
execute "ALTER DATABASE `#{ActiveRecord::Base.connection.current_database}` CHARACTER SET utf8;" execute "ALTER DATABASE `#{ActiveRecord::Base.connection.current_database}` CHARACTER SET utf8;"
ActiveRecord::Base.connection.tables.each do |table| tables.each do |table|
execute "ALTER TABLE `#{table}` CHARACTER SET = utf8;" execute "ALTER TABLE `#{table}` CHARACTER SET = utf8;"
end end

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150106050733) do ActiveRecord::Schema.define(version: 20150106050734) do
create_table "account_deletions", force: true do |t| create_table "account_deletions", force: true do |t|
t.string "diaspora_handle" t.string "diaspora_handle"
@ -66,7 +66,6 @@ ActiveRecord::Schema.define(version: 20150106050733) do
t.string "name" t.string "name"
t.string "ask", limit: 128 t.string "ask", limit: 128
t.string "subscription", limit: 128, null: false t.string "subscription", limit: 128, null: false
t.text "groups"
end end
add_index "chat_contacts", ["user_id", "jid"], name: "index_chat_contacts_on_user_id_and_jid", unique: true, using: :btree add_index "chat_contacts", ["user_id", "jid"], name: "index_chat_contacts_on_user_id_and_jid", unique: true, using: :btree
@ -242,7 +241,7 @@ ActiveRecord::Schema.define(version: 20150106050733) do
t.text "data", null: false t.text "data", null: false
end end
add_index "o_embed_caches", ["url"], name: "index_o_embed_caches_on_url", using: :btree add_index "o_embed_caches", ["url"], name: "index_o_embed_caches_on_url", length: {"url"=>255}, using: :btree
create_table "open_graph_caches", force: true do |t| create_table "open_graph_caches", force: true do |t|
t.string "title" t.string "title"
@ -430,11 +429,11 @@ ActiveRecord::Schema.define(version: 20150106050733) do
create_table "reports", force: true do |t| create_table "reports", force: true do |t|
t.integer "item_id", null: false t.integer "item_id", null: false
t.string "item_type", null: false
t.boolean "reviewed", default: false t.boolean "reviewed", default: false
t.text "text" t.text "text"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "item_type", null: false
t.integer "user_id", null: false t.integer "user_id", null: false
end end

View file

@ -119,8 +119,11 @@ module Configuration
end end
def postgres? def postgres?
defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && ActiveRecord::Base.connection.adapter_name == "PostgreSQL"
ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) end
def mysql?
ActiveRecord::Base.connection.adapter_name == "Mysql2"
end end
def bitcoin_donation_address def bitcoin_donation_address