Hassan Schroeder wrote:
> On Thu, Mar 4, 2010 at 5:18 AM, Marnen Laibow-Koser
> <li...@ruby-forum.com> wrote:
> 
>> However, your original example is problematic. You appear to be using
>> migrations for seed data. This is a terrible idea.
> 
> Why?

For several reasons.  The two most compelling for me are as follows.

* First of all, it's conceptually wrong.  Migrations are about the 
database *schema*, not the data.  Each migration file should contain 
whatever is necessary to bring the schema from one consistent state to 
the next.  Those schema changes may include munging the existing data to 
fit the new schema's representation, but they can never include seed 
data.  Once they include seed data, migrations step outside their proper 
role of defining the schema.

* Second, putting seed data in migrations forces you to initialize new 
installations by running all your migrations starting from zero.  This 
is a known bad practice, and I think even members of the Rails core team 
recommend against it; in general, it's better to set up a new 
installation by running rake db:schema:load, but if your seed data is in 
your migrations, you can't do that.

I can think of no good reasons to put seed data in migrations, and many 
good reasons not to.  Conclusion: don't to it.

> 
> --
> Hassan Schroeder ------------------------ hassan.schroe...@gmail.com
> twitter: @hassan

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to