Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    Wouldn't the last code restore the production database? sounds a bit dangerous Commented Jun 9 at 12:55
  • 1
    Point is to use a test database, snapshotted to how you want it to look at the start of each test. Then you revert to the test DB's snapshot. No you wouldn't use prod data for this. Commented Jun 9 at 12:58
  • What, no, then you will have the data after the test ran. I'm not sure you're quite aware of how this is working. Get the DB into a known state. Create snapshot. Run test on current DB, not the snapshot. Revert current DB to the snapshot. Now it's back to the known state. Commented Jun 9 at 13:18
  • you might be right, it was a while ago, forget what i wrote :D Commented Jun 9 at 13:31
  • Wish I’d known about this a couple of years ago to clean out my local DB :) - I had code to drop the indexes, truncate the tables and recreate the indexes… Commented Jun 9 at 14:05