From 706f7e9c3e2a4807e37b1a1ef21febd6444adf6f Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Tue, 31 May 2016 23:15:46 +0900 Subject: Do not include default column limit in schema.rb Follow up of #20815. ```ruby class CreatePeople < ActiveRecord::Migration[5.0] def change create_table :people do |t| t.integer :int t.bigint :bint t.text :txt t.binary :bin end end end ``` Result. In postgresql and sqlite3 adapters: ```ruby ActiveRecord::Schema.define(version: 20160531141018) do create_table "people", force: :cascade do |t| t.integer "int" t.bigint "bint" t.text "txt" t.binary "bin" end end ``` In mysql2 adapter: ```ruby ActiveRecord::Schema.define(version: 20160531141018) do create_table "people", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t| t.integer "int" t.bigint "bint" t.text "txt", limit: 65535 t.binary "bin", limit: 65535 end end ``` After this patch: ```ruby ActiveRecord::Schema.define(version: 20160531141018) do create_table "people", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t| t.integer "int" t.bigint "bint" t.text "txt" t.binary "bin" end end ``` --- .../lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb') diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 44b4b547f3..718a6c5b91 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -41,14 +41,14 @@ module ActiveRecord NATIVE_DATABASE_TYPES = { primary_key: "int auto_increment PRIMARY KEY", string: { name: "varchar", limit: 255 }, - text: { name: "text" }, + text: { name: "text", limit: 65535 }, integer: { name: "int", limit: 4 }, float: { name: "float" }, decimal: { name: "decimal" }, datetime: { name: "datetime" }, time: { name: "time" }, date: { name: "date" }, - binary: { name: "blob" }, + binary: { name: "blob", limit: 65535 }, boolean: { name: "tinyint", limit: 1 }, json: { name: "json" }, } -- cgit v1.2.3