It looks like the major DB adapters can get at the index info, so that  
hurdle is passed.

This post got me thinking more on syntax:
http://robots.thoughtbot.com/post/163627511/a-grand-piano-for-your-violin

The syntax described below is good for generic indexes (multiple  
fields, etc), but decidedly un-DRY for basic indexes. What about  
adding an :index option to the fields DSL? So it might look more like:

fields do
   some_field :integer
   indexed_field, :integer, :index => true
end

Some of the options to add_index can be determined automatically - for  
instance, a field declared with :unique => true would seem likely to  
want a unique index. Passing a string instead of true would allow a  
custom name for the index.

It could even be taken a step farther, adding an implicit :index to  
belongs_to, so foreign keys are always indexed.

Thoughts? If people like this, I can work on rolling it into the other  
changes I've got waiting in the queue for the migration generator  
(better behavior of HABTM, adding fields in STI subclasses, better  
ignoring of non-Hobo tables).

--Matt Jones

On Aug 11, 2009, at 3:46 PM, Owen wrote:

>
> Thanks, Matt. I like what you outlined.  Yes,  syncing with the DB is
> the trickiest.
>
> On Aug 11, 10:18 am, Matt Jones <[email protected]> wrote:
>> The most straightforward would be a direct translation of the
>> parameters of add_index inside of fields:
>>
>> fields do
>>    # ... blah blah blah
>>
>>    index :column_name
>>    index :other_column, :unique => true
>>    index :a_whole, :bunch_of, :columns_to_index, :name => 'foobar'
>> end
>>
>> The only question mark is the level of support for getting these
>> settings back out of the DB, so the migration generator can figure  
>> out
>> what's changed. That needs some investigation.
>>
>> --Matt Jones
>>
>> On Aug 11, 2009, at 10:11 AM, Owen wrote:
>>
>>
>>
>>> I've been pushing for that in Hobo.  How would you like the
>>> declaration to look?
>>
>>> On Aug 11, 6:02 am, Tiago Franco <[email protected]> wrote:
>>>> I've been declaring indexes on the migrations. This feature could
>>>> come
>>>> handy.
>>
>>>> TF
>>
>>>> On Aug 11, 8:34 am, Helder Ribeiro <[email protected]> wrote:
>>
>>>>> Is there any way of declaring indexes in the models themselves,  
>>>>> like
>>>>> with fields?
>>
>>>>> Thanks,
>>
>>>>> Helder
>>
>>>>> http://helderribeiro.net
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to