AWDwR2: Loading data in migrations

The new chapter in Agile Web D. with Rails talks about using
migrations to load data from fixtures. This is a great idea, I’ve
wanted to
do this. This allows you a good way to create sample data that you can
during development, testing or demoing of an application. My question
how do you keep it separated from the real data? For example, say you
a User and Account model. You might end up with migrations like this:


When you go to production, you don’t want the sample users or accounts
loaded, but when you run rake db:migrate, they will get loaded. Is
there a
way to handle this? It almost seems like loading sample data should be
handled by another script, not in the migrations.

I would do the load in the migration file that corresponds to the
model you’re creating. So, in your example, your 002 file data would
be loaded in 001.

As for live/dev, you could check for the environment you’re in and
base data loading on that. If in dev, load dev data, etc.