We are writing a migration which will be used to create the initial version of the database. We want to use the same migration to populate both an Oracle and MySQL database. We would like to detect the database type so that we can add foreign keys to Oracle, but don''t want to do it for the SQLite database. Is there a method we can call from ActiveRecord which gives us the database type we are connected to? Thanks in advance, Don McClean --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2007-Mar-08 18:29 UTC
Re: Migration detection of database type (Oracle and SQLite)
> We are writing a migration which will be used to create the initial > version of the database. We > want to use the same migration to populate both an Oracle and MySQL > database. > > We would like to detect the database type so that we can add foreign > keys to Oracle, but > don''t want to do it for the SQLite database. Is there a method we can > call from ActiveRecord > which gives us the database type we are connected to?Not sure what method, but if you look at the ''connection'' method of the adapter you should find something interesting in there... http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001071 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
javier ramirez
2007-Mar-08 19:43 UTC
Re: Migration detection of database type (Oracle and SQLite)
> We would like to detect the database type so that we can add foreign > keys to Oracle, but don''t want to do it for the SQLite database. Is there a method we can > call from ActiveRecord which gives us the database type we are connected to? >For something similar i''ve used a case like this case ActiveRecord::Base.connection.adapter_name.downcase when /mysql[.]*/ .... hope it helps! javier ramirez -------- Estamos de estreno... si necesitas llevar el control de tus gastos visita http://www.gastosgem.com !!Es gratis!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---