I just got AWDWR, second edition. I wanted to bone up on migrations, so I read the part of page 79 that starts with "Let''s create a data-only migration" and happily walks you through the generation of a migration called add_test_data. Later, in the migrations chapter on page 273, the book shows a generation of a migration called load_users_data. At the bottom of the page there is the dire warning: "Be warned: the only data you should load in migrations is data that you''ll also want to see in production ... Do not load test data into your application this way." These are seemingly contradictory. I don''t see any further clarification in the book. Is there a way to create a test-data-only migration that doesn''t get inserted into the migration versioning system? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 1/5/07, Mark Thomas <mrt-gkTqyYPWbQbz1n+OaKNE4w@public.gmane.org> wrote:> Is there a way to create a test-data-only migration that doesn''t get > inserted into the migration versioning system?You can specify the environment when running migrations RAILS_ENV=test rake db:migrate -- Greg Donald http://destiney.com/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Fri, Jan 05, 2007 at 10:45:29PM -0000, Mark Thomas wrote:> > I just got AWDWR, second edition. I wanted to bone up on migrations, so > I read the part of page 79 that starts with "Let''s create a data-only > migration" and happily walks you through the generation of a migration > called add_test_data. > > Later, in the migrations chapter on page 273, the book shows a > generation of a migration called load_users_data. At the bottom of the > page there is the dire warning: "Be warned: the only data you should > load in migrations is data that you''ll also want to see in production > ... Do not load test data into your application this way." > > These are seemingly contradictory. I don''t see any further > clarification in the book. > > Is there a way to create a test-data-only migration that doesn''t get > inserted into the migration versioning system?Sort of, one of the basic ideas of migrations is that you have a repeatable set of steps that will be applied uniformly on every deployment of your application, be it development, test or production. As such you probably shouldn''t be doing anything environment specific in your migrations. But of course migrations are just Ruby code. So you could make the insertion conditional and only do it if your RAILS_ENV is test. This is a rather clumsy hack IMHO though. You would probably be better off with a good set of fixtures or you could use one of the fixture loaders. -- Cheers, - Jacob Atzen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---