Hi all, I''m loading fixture data via migrations into my application using the method described in the Agile book. This works beautifully for development and production environments. The only problem is, I don''t want these particular migrations to run when I do rake db:migrate RAILS_ENV=test. For one, there is no reason to being loading data into the test db. And, more problematic for me, this causes foreign key constraint errors which abort the rake with the test db because I''m using Redhillonrails'' foreign_key_migrations plugin. Any tips? Thanks! Ryan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
def self.up unless RAILS_ENV="test" ... migration stuff ... end end Jason On 4/10/07, Ryan Williams <lists-UUWUnGlUeGY@public.gmane.org> wrote:> > Hi all, > > I''m loading fixture data via migrations into my application using the > method described in the Agile book. This works beautifully for development > and production environments. The only problem is, I don''t want these > particular migrations to run when I do rake db:migrate RAILS_ENV=test. For > one, there is no reason to being loading data into the test db. And, more > problematic for me, this causes foreign key constraint errors which abort > the rake with the test db because I''m using Redhillonrails'' > foreign_key_migrations plugin. > > Any tips? > > Thanks! > > Ryan > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yep, works perfectly. I had tried that but got the syntax wrong apparently. Thanks Jason! On 4/10/07, Jason Roelofs <jameskilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > def self.up > unless RAILS_ENV="test" > ... migration stuff ... > end > end > > Jason > > On 4/10/07, Ryan Williams < lists-UUWUnGlUeGY@public.gmane.org> wrote: > > > > Hi all, > > > > I''m loading fixture data via migrations into my application using the > > method described in the Agile book. This works beautifully for development > > and production environments. The only problem is, I don''t want these > > particular migrations to run when I do rake db:migrate RAILS_ENV=test. For > > one, there is no reason to being loading data into the test db. And, more > > problematic for me, this causes foreign key constraint errors which abort > > the rake with the test db because I''m using Redhillonrails'' > > foreign_key_migrations plugin. > > > > Any tips? > > > > Thanks! > > > > Ryan > > > > > > > > > >-- Ryan Williams Lead Developer Capocus! http://abra.capoc.us Productive Web Publishing --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Actually, I spoke too soon. This code doesn''t actually work. I thought it did because the argument passed, but it just ignored the migration on all environments. It seems that rake pulls RAILS_ENV from the actual setting in the application, not from the option passed at the command line (rake db:migrate RAILS_ENV=test), which only seems to change the db it''s acting upon. Someone tell me if I''m wrong. I also tried this, which also skips the migration on all environments: unless ENV[''RAILS_ENV''] = "test" # migration stuff end and, the following caused *all three* environments to run the migration. if ENV[''RAILS_ENV''] = "development" || "production" # migration stuff end which I assumed was because the application is set to development. But for some crazy reason, this runs the migration on all environments as well!: if ENV[''RAILS_ENV''] = "production" # migration stuff end That, just doesn''t make sense. Anyone? On 4/10/07, Ryan Williams <lists-UUWUnGlUeGY@public.gmane.org> wrote:> > Yep, works perfectly. I had tried that but got the syntax wrong > apparently. Thanks Jason! > > On 4/10/07, Jason Roelofs < jameskilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > def self.up > > unless RAILS_ENV="test" > > ... migration stuff ... > > end > > end > > > > Jason > > > > On 4/10/07, Ryan Williams < lists-UUWUnGlUeGY@public.gmane.org> wrote: > > > > > > Hi all, > > > > > > I''m loading fixture data via migrations into my application using the > > > method described in the Agile book. This works beautifully for development > > > and production environments. The only problem is, I don''t want these > > > particular migrations to run when I do rake db:migrate RAILS_ENV=test. For > > > one, there is no reason to being loading data into the test db. And, more > > > problematic for me, this causes foreign key constraint errors which abort > > > the rake with the test db because I''m using Redhillonrails'' > > > foreign_key_migrations plugin. > > > > > > Any tips? > > > > > > Thanks! > > > > > > Ryan > > > > > > > > > > > > > > > > > > > > -- > Ryan Williams > Lead Developer > Capocus! > http://abra.capoc.us > Productive Web Publishing-- Ryan Williams Lead Developer Capocus! http://abra.capoc.us Productive Web Publishing --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Williams wrote the following on 10.04.2007 23:02 :> Actually, I spoke too soon. This code doesn''t actually work. I thought > it did because the argument passed, but it just ignored the migration > on all environments. It seems that rake pulls RAILS_ENV from the > actual setting in the application, not from the option passed at the > command line (rake db:migrate RAILS_ENV=test), which only seems to > change the db it''s acting upon. Someone tell me if I''m wrong. > > I also tried this, which also skips the migration on all environments: > > unless ENV[''RAILS_ENV''] = "test" > # migration stuff > end > > and, the following caused *all three* environments to run the migration. > > if ENV[''RAILS_ENV''] = "development" || "production" > # migration stuff > end > > which I assumed was because the application is set to development. But > for some crazy reason, this runs the migration on all environments as > well!: > > if ENV[''RAILS_ENV''] = "production" > # migration stuff > end > > That, just doesn''t make sense. Anyone?I''ve only 2 bytes for you : = Hints : 1/ any value not nil or false is true 2/ var = value returns value :-) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> > Hints : >1/ any value not nil or false is true> 2/ var = value returns value:-)>Hahaha! Oh man... I was *way* over analyzing that one. Jeez... thanks for the Programming 101 kick in the arse Lionel. Step away from coding for a month and my mind goes to mush on the basics. :) The winner: unless ENV[''RAILS_ENV''] == "test" # migration stuff end Puuuurfect. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yeah, I''ll take partial responsibility for that, as I did only put in a single ''='' in my post. Sorry about that. Jason On 4/10/07, Ryan Williams <lists-UUWUnGlUeGY@public.gmane.org> wrote:> > Hints : > > > 1/ any value not nil or false is true > > 2/ var = value returns value > > :-) > > > > Hahaha! Oh man... I was *way* over analyzing that one. Jeez... thanks for > the Programming 101 kick in the arse Lionel. Step away from coding for a > month and my mind goes to mush on the basics. :) > > The winner: > > unless ENV[''RAILS_ENV''] == "test" > # migration stuff > end > > Puuuurfect. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---