Hi Rails core team, I've been mulling over an idea for a bit of new syntax, want to hear what you think about it.
Two of the most common things I do as a developer when generating a new migration are (1) add defaults to help avoid nil errors and (2) add indices to attributes like foreign keys for performance. The migration generator comes with nice syntax that makes adding indices easy: $ bin/rails generate migration AddPartNumberToProducts part_number:string: index (from http://guides.rubyonrails.org/migrations.html#creating-a-standalone-migration) But there's no corresponding syntax for adding defaults. You generate the migration, find the generated file, add defaults by hand and then run the migration. What about a way to add defaults to new migrations from the command line? Could look like this: rails g migration AddGearsToBicycles gears:integer[default:3] Or in a new model: rails g model Bicycle mileage:integer[default:0] gears:integer[default:3] Improvements or suggestions on the proposed syntax? Any feedback would be much appreciated! Thanks everyone. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.