-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not include column limit in schema.rb if it matches the default #20815
Do not include column limit in schema.rb if it matches the default #20815
Conversation
When working on engines that supports multiple databases, it's very annoying to have a different schema.rb output based on which database you use. MySQL being the primary offender. This patch should reduce the disparities a bit.
I sympathize with your pain but this is giving me an uneasy feeling when viewed in the context of applications :/ |
@chancancode What do you mean? Are you afraid this will cause issues to users? |
Yeah; in theory, But I also don't have a very concrete concern/objection other than the vague uneasy feeling, so if others feel that it is fine, maybe I am just over-thinking it (shrug) @matthewd too? |
I actually just remembered I totally forgot to mention the main pain point: When dumping schema with MySQL the boolean will end up as: t.boolean 'foo', limit: 1 Because in the end MySQL's booleans are So if this PR is a no go, then I think we should at least ignore the length property for column types that doesn't require it. |
I think I'm tentatively in favour of this, on the basis that we'll have a proper migration API versioning mechanism Real Soon Now, which will better address the "but what if the default changes" concern. The current behaviour isn't an accident, though: 2c76793 |
…it-is-default Do not include column limit in schema.rb if it matches the default
Follow up of rails#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 ```
When working on engines that supports multiple databases, it's
very annoying to have a different schema.rb output based on which
database you use. MySQL being the primary offender.
This patch should reduce the disparities a bit.
Next on the list could be
using: :btree
for mysql indexes.cc @rafaelfranca