3 ms·
Do you store test data in the template? My team uses a migration framework (in our case Flyway) such that we can easily create completely fresh DBs on a factor
by jayd16 6y ago
Do you store test data in the template?
My team uses a migration framework (in our case Flyway) such that we can easily create completely fresh DBs on a factory fresh(+ user roles) instance of Postgres. We do this for our testing as well. This means the schema tools are always tested as well. Is there a benefit to using templates? They're faster perhaps?
- flavor8 6y agoWe use flyway to create a template. Then each test that mutates the DB automatically invokes a cleanup routine which recreates the test DB from the template. You get into hot water around the connection pooling, but it's much, much faster than refreshing using flyway.
- tln 6y agoI'm using templates as well for the speedup in testing. We build a postgresql docker image with the migrations + seed data, then create a few databases for parallel testing. When migration or seed files have changed, rules rebuild the image. That way the price of migration (about 2 minutes for our Django app) isn't paid on every test run. Creating a DB from template is 2 seconds.
- KingOfCoders 6y agoFor 10 workers it takes <0.5 seconds to create 10 databases from the template. Test data is created from within tests.