Migrations confusion in AWDWR v2

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 can specify the environment when running migrations

RAILS_ENV=test rake db:migrate

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.