Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transaction vs Truncation Database Cleaner

Recently I had a problem with one of my cucumber scenarios. Certain entries in my test database were disappearing whilst the feature was running. I solved the problem by changing the line

DatabaseCleaner.strategy = :transaction

to

DatabaseCleaner.strategy = :truncation

I'm not sure why that helped. There is a table on the database cleaners gem webpage, but it dosen't really say what the two terms mean. Any help on understanding the difference between the two concepts would be great.

like image 315
elliance Avatar asked Sep 14 '11 16:09

elliance


1 Answers

Putting it in a very simple way: truncation removes all data from the database and transaction rollbacks all changes that has been made by the running scenario.

like image 190
socjopata Avatar answered Oct 24 '22 05:10

socjopata