4 ms·
I'm still surprised they removed the formatting for db/schema.rb which I rely on quite a bit to remind myself what properties models have, whether or not their
by 3pt14159 10y ago
I'm still surprised they removed the formatting for db/schema.rb which I rely on quite a bit to remind myself what properties models have, whether or not their status can be set to null, and how many digits of precision my decimal columns have.
I went as far as writing my own formatter which consumes the db/schema.rb generated string and outputs another string with better formatting. The code is kinda shaky because I wrote it in a rush, but if anyone is interested I can share it with them.
- superplussed 10y agoWhat formatting did they remove, the indentation?
- poorman 10y agoYou should check out the `annotate` gem.
- 6t6t6t6 10y agoAnnotate is great! I cannot work in a Rails app without annotate.
- dorianm 10y agoI'm interested, I would use `rubocop -a` personally.
- ezekg 10y agoAs far as I can tell, they only modified the formatting used for lining up column options[0], not all formatting for the file. I hated that formatting anyways, due to the diffs it produced. I admit that I haven't tested a migration on 5.1 yet and am just looking at the commit log so maybe I'm wrong. [0]: https://github.com/rails/rails/pull/25675 https://github.com/rails/rails/pull/25675
- 3pt14159 10y agoImagine wanting to quickly scan which attributes are required and which ones aren't. It used to be easy, find the "null" option with your eyes then scan downwards. Plus it just looks more messy now.
- ezekg 10y agoSure, but I still wasn't a fan of the diffs that it produced—and like poorman said, if you really need that then use the annotate gem which lets you check the model file for that info instead of digging through a giant schema file.
- 3pt14159 10y agoNot what I want. No syntax highlighting, and annoying when I don't need it. Plus I always read the migration file for the db/schema diff anyway. Also, sometimes I want one place to quickly hop around in to remind myself how one area of the codebase snaps together. I never intentionally write code that is harder to read to produce readable diffs, and I don't know why generating schema.rb should be any different.