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
use
during development, testing or demoing of an application. My question
is
how do you keep it separated from the real data? For example, say you
have
a User and Account model. You might end up with migrations like this:

001_create_users.rb
002_load_sample_users.rb
003_create_accounts.rb
004_load_sample_accounts.rb

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.

Sean