Forum: Ruby on Rails ID of adapter in migrations

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.
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-04-02 17:04
Rails 2.3

How does one identify the adapter that a migration is using?  I have
some SQL code that only applies if the postgresql adapter is involved
and I wish to put my execute method inside a suitable conditional.
However, I cannot see a way to get this information from an instance of
ActiveRecord::Migration.  Nonetheless, some means must exist for
migrations to work.

How do I ID the DBMS adapter that the migration is using?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-04-02 17:21
(Received via mailing list)
On 2 Apr 2009, at 16:04, James Byrne wrote:

>
> How do I ID the DBMS adapter that the migration is using?

You could check the class of  ActiveRecord::Base.connection

Fred
16b26104470ae1b64958f3caa836c193?d=identicon&s=25 Danny Burkes (dburkes)
on 2009-04-02 17:56
> How do I ID the DBMS adapter that the migration is using?

if ActiveRecord::Base.configurations[RAILS_ENV]["adapter"] == "mysql"

etc.

- D
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-04-02 21:55
Frederick Cheung wrote:

> You could check the class of  ActiveRecord::Base.connection
>
> Fred

Works for me.  Thanks.
This topic is locked and can not be replied to.