Refactoring existing data

I recently inherited an insurance application which stored member information in the same table as a claim. In order to improve this application I would like to refactor it so that a member model exists which has many claims. I am a bit stuck on the best way to go about testing this to ensure the data remains consistent and that all claims are linked to the correct member. Would it be best to perform this type of operation in a migration and if so how would you go about testing it?

Yes, I’d probably do this via a migration.

One way to test is to pull the production data to your local database and run the migration. Poke around and make sure it looks correct.