Dan😏
PPrisma
•Created by Christophe on 2/10/2025 in #help-and-questions
Prisma postgres and replicas
if you're using a prisma-managed database on
console.prisma.io
, you won't have direct access to modify postgresql settings like wal_level
or create a replication user manually
you know, prisma cloud manages the database for you, so low-level configuration changes aren’t exposed19 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
it spins up a real postgresql instance in the background, runs your tests, and automatically cleans
55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
pg_tmp
lets you create a temporary postgresql database without needing docker55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
yeah, that's right
55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
so, while
pg-mem
work today, it's smart to keep an eye on whether it meets your needs as your app grows55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
anyway, if you wanna long-term reliability, you might wanna look at altervatives like testcontainers for node.js,
pg_tmp
, using a ram-backed postgresql instance55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
that said,
pg-mem
is still useful for lightweight unit tests where you dont need full postgresql behavior55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
since it mimics postgresql using javascript, it's not guaranteed to stay 100% in sync with newer postgresql features, optimizaions, or quirks
55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
pg-mem
is great for now, but yeah, there's always a risk that it could become outdated or inaccurate over time55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
good question~~
55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
so the best approach depends on what you’re testing
- simple unit tests →
pg-mem
is great
- more realistic database behavior → pg_tmp
or a real sostgres instance55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
so if your queries are simple like basic crud, joins etc, pg-mem is a solid choice
but if you need full postgresql behavior like complex transactions, foreign key constraints, or postgis, then you’d need a real postgres instance like running one on a ram disk or using
pg_tmp
for a temporary database55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
so,
pg-mem
isnt postgresql itself, but a library that mimics its behavior using javascript
it’s super fast and great for unit tests where you dont need full postgresql features like advanced indexing, triggers, or extensions55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
yeah, i get the confusion
you know, postgresql itself doesn’t have a true "in-memory" mode like sqlite, but
pg-mem
works differently, it simulates a postgresql database entirely in memory, without actually running a real postgres instance55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
so if you need real postgres behavior,
pg-mem
or using a RAM-disk-backed postgresql instance is better55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
in my exp,
pg-mem
is great for unit tests but doesnt fully replicate postgresql behavior, so it might not work well for complex queries55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
if you are testing api routes using jest + supertest, you can do something like this
55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
and next, you have to use
pg-mem
in jest tests55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
then, set up an in-memory database
55 replies
PPrisma
•Created by nhan.nguyenvan on 2/10/2025 in #help-and-questions
Find the way to write unit-test by postgres in memory db
npm install pg-mem
- install55 replies