Option not to line up column attributes in schema.rb

schema.rb git diff are often harder to read as adding a column or argument could add/remove whitespace for other columns definitions.

Let’s say I have a users table with a first_name column:

create_table “users”, force: :cascade do |t|

t.string “first_name”, null: false

end

``

If I add another column with a limit, whitespaces will be added to my schema for the first_name line as well:

create_table “users”, force: :cascade do |t|

t.string “first_name”, null: false

t.string “zipcode”, limit: 5, null: false

end

``

I understand it is intended as a feature but it would be nice to offer an opt-out option to generate the following schema instead:

create_table “users”, force: :cascade do |t|

t.string “first_name”, null: false

t.string “zipcode”, limit: 5, null: false

end

``

I have some working code for this option, I’m waiting for your thoughts before doing a PR.

Yes please :+1:

Dealing with that cruft mismatch in schema.rb is a headache — would defiantly speed up developer productivity if we figured out the reasons why different developers’ systems produce slightly different files (this being one of them) and killed those nuances so my schema.rb didn’t change itself even when there are no schema changes.

It is definitely something that does not make me :happy_face: and Matz said Ruby was supposed to make me happy.

-Jason

Positive over here. People may occasionally have a look at db/schema.rb, but it's main use case is to automate stuff.

Personally, I wouldn't even make it configurable in this case, we are not talking about generating a non-readable dump. Some people would even write it like that if it was their code. A matter of preference, no big deal.

+1

I had this idea too. It’s annoying when looking at diff when something changes and it’s not obvious.

If someone wants to take a stab at it, please feel free.

-Prem