CodePark/ questions / Databases, Testcontainers & test data
START PRACTICINGPRACTICE
Backend question · Backend testing › Databases, Testcontainers & test data

Where should the schema of an integration test database come from?

The same migrations you run in production, applied once per run or per worker database before the tests

Use the same migrations you run in production. Running the real migrations tests the migrations too. It also keeps the test schema identical to production, including indexes, constraints and triggers.

The ORM's
synchronize: true is the tempting wrong answer. It builds the schema from your entity code, not from the migrations. So it can hide a missing or broken migration, and that bug only shows up in production.