| ▲ | pak9rabid 3 hours ago | |
I was able to accomplish this by doing each test within its own transaction session that gets rolled-back after each test. This way I'm allowed to modify the database to suit my needs for each test, then it gets magically reset back to its known state for the next test. Transaction rollbacks are very quick. | ||
| ▲ | francislavoie 11 minutes ago | parent | next [-] | |
Unfortunately a lot of our tests use transactions themselves because we lock the user row when we do anything to ensure consistency, and I'm pretty sure nested transactions are still not a thing. | ||
| ▲ | fanf2 15 minutes ago | parent | prev | next [-] | |
This doesn’t work for testing migrations because MySQL/MariaDB doesn’t support DDL inside transactions, unlike PostgreSQL. | ||
| ▲ | hu3 2 hours ago | parent | prev [-] | |
As a consultant, I saw many teams doing that and it works well. The only detail is that autoincrements (SEQUENCEs for PotgreSQL folks) gets bumped even if the transaction rollsback. So tables tend to get large ids quickly. But it's just dev database so no problem. | ||