Hi folks, Just after a ''best-practise'' recommendation here really, I am deploying a series of applications to EY and for each one, need to setup the database with some default settings / user account etc etc. What is the best way to write a few initial rows to a vanilla database? I''ve looked into using the deploy hooks on EY but it doesn''t seem to cover DB interaction. . . I know I could create a standard backup file and restore this each time but it feels like there should be a better way! Thanks, Paul -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
When you deploy you can specify a migration task. By default it is "rake db:migrate". For your new applications, try "rake db:migrate db:seed", where db:seed is the Rails 3 hook for setting up new database content. Remember to change your migration field back to "rake db:migrate" after the first successful deploy, other wise you will re-seed again and again :) -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/T8g0RqtkJNEJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Great - just what I was looking for with the db:seed command - thanks Paul On Sep 12, 1:46 pm, Dr Nic <drnicwilli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> When you deploy you can specify a migration task. By default it is "rake > db:migrate". For your new applications, try "rake db:migrate db:seed", where > db:seed is the Rails 3 hook for setting up new database content. > > Remember to change your migration field back to "rake db:migrate" after the > first successful deploy, other wise you will re-seed again and again :)-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
http://www.kbedell.com/2011/03/15/seed-data-versus-testing-data-and-custom-rake-tasks-for-ruby-on-rails/ Here''s a blog post I wrote on this subject with some sample code. It covers the difference between loading ''seed'' data which is intended to live as a permanent part of the production database (for example, role names or state codes) and loading sample data just used for testing *for example, fake test accounts). Hopefully it''ll help. There''s some sample code in the post. -Kevin On Mon, Sep 12, 2011 at 9:33 AM, paulo <paul.a.taylor84-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Great - just what I was looking for with the db:seed command - thanks > > > Paul > > On Sep 12, 1:46 pm, Dr Nic <drnicwilli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> When you deploy you can specify a migration task. By default it is "rake >> db:migrate". For your new applications, try "rake db:migrate db:seed", where >> db:seed is the Rails 3 hook for setting up new database content. >> >> Remember to change your migration field back to "rake db:migrate" after the >> first successful deploy, other wise you will re-seed again and again :) > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Kevin. However you wish to load data, the migration task can take a command and it''s output is included in the deploy logs. Nov -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.