Sounds good. Keep in mind that you could potentially be dealing with
dynamic values (such as Date, Time, and co) and also binary data, ltrees,
and so on. Ideally you want to cover all these types, which is prehaps why
this was not done in the first place.

On Tue, Dec 2, 2014 at 8:22 AM, Austin Story <lonnieast...@gmail.com> wrote:

> I like it too.  Looks like it would be an easy change as well.
>
> On Monday, December 1, 2014 4:18:47 PM UTC-6, Alex Soble wrote:
>>
>> 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.
>



-- 
Mohamed Wael Khobalatte

-- 
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.

Reply via email to