Background Image
Table of Contents Table of Contents
Previous Page  456 / 478 Next Page
Information
Show Menu
Previous Page 456 / 478 Next Page
Page Background

What happened was that some of the existing data in the database violated the integrity

constraint, so the database was complaining when I tried to apply it.

In order to deal with this sort of problem, we’ll need to build a “data migration”. Let’s

first set up a local environment to test against.

Running a Test Migration Locally

We’ll use a copy of the live database to test our migration against.

Be very, very, very careful when using real data for testing. For ex‐

ample, you may have real customer email addresses in there, and you

don’t want to accidentally send them a bunch of test emails. Ask me

how I know this.

Entering Problematic Data

Start a list with some duplicate items on your live site, as shown in

Figure D-1 .

Figure D-1. A list with duplicate items

Copying Test Data from the Live Site

Copy the database down from live:

428

|

Appendix D: Testing Database Migrations