Forum: Ruby on Rails how to create index using btree

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Geekforaday-Learnerforlifetime (Guest)
on 2008-11-03 12:47
(Received via mailing list)
Hi,

I want to add a migration to create an index using btree , googled a
little but couldn't find anything thats relevant.

is this possible in rails ? or is there a work around ?

appreciate your help , thanks

-CG
Daniel B. (Guest)
on 2008-11-03 14:28
(Received via mailing list)
On Nov 3, 9:46 pm, Geekforaday-Learnerforlifetime
<removed_email_address@domain.invalid> wrote:
> Hi,
>
> I want to add a migration to create an index using btree , googled a
> little but couldn't find anything thats relevant.
>
> is this possible in rails ? or is there a work around ?
>
> appreciate your help , thanks
>
> -CG

I think btree is a fairly common default.  For instance it's the
default in postgres, right?
So if you just used the rails 'add_index' you'd get a btree index.
It looks like add_index doesn't pass on extra options though (there
might be some
method that does this in rails I just don't know it). So if you needed
to
specify the index method, you might have to execute the sql manually
in your migration.
  YourARClass.connection.execute('CREATE INDEX ... USING btree...')
You'll have to consult your db docs to establish its capabilities and
sql to use.


--
Daniel B.
This topic is locked and can not be replied to.