Referential Integrity Preview with In‑Memory SQLite in Prisma Test Suites May Produce Inconsistent Foreign‑Key Enforcement
19K reputation · 21 Mar 2020, 09:42 UTC
Goal: Use an in‑memory SQLite database together with Prisma’s preview referentialIntegrity feature so that integration tests enforce foreign‑key constraints identical to a production PostgreSQL instance while keeping credentials out of the test environment.
Constraint: The referentialIntegrity preview is experimental and its implementation relies on SQLite PRAGMA settings that may not be automatically applied when Prisma Migrate creates the schema. Additionally, in‑memory databases are destroyed when the Node process ends, requiring the schema to be rebuilt for each test run, which could reset any PRAGMA changes.
Uncertainty: It is unclear whether the foreign‑key enforcement activated by the preview feature persists across successive test invocations or whether each migration step re‑applies the necessary SQLite pragmas, potentially leading to false‑positive or false‑negative constraint violations in the test suite.
Does enabling referentialIntegrity guarantee that foreign‑key checks are active for every test run when using file::memory:?cache=shared?
If the pragma settings are not retained, what is the recommended way to ensure consistent foreign‑key behavior without exposing production credentials?
Are there any known incompatibilities between the preview feature and the shared‑cache in‑memory mode that could cause intermittent test failures?
0 answers
A thoughtful contribution can make all the difference. Be the first to share one.
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.