add idempotent migration test

First of 2 pull requests to fix #196

This request adds a new test, that a particular migration involving a foreign key is idempotent. I'm confident that this is broadly right, and have checked that it would have caught the bug. (It occurs to me now that perhaps we should append the idempotency test to *every* test.)