adapter-pg: connectToShadowDb connects to the main database when built from a connection string
Maintainers usually reply within 1 day
@cestercian is already working on this.
Since Nov 24, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, postgresql, typescript
- Domain
- databases
Research direction
Start in packages/adapter-pg/src/pg.ts at PrismaPgAdapterFactory.connectToShadowDb() and follow how this.config is stored when the adapter is built from a connection string. Read pg/lib/connection-parameters.js to confirm the connection string overrides database. Change the shadow pool's config so the temporary database name wins, then add a unit test in the adapter-pg test suite asserting new pg.Client(pool.options).connectionParameters.database equals the temporary database name; done means that test passes for both string-built and object-built configs.
Written by the indexing model from the issue text.
Description
PrismaPgAdapterFactory.connectToShadowDb() in packages/adapter-pg/src/pg.ts creates a temporary database, prisma_migrate_shadow_db_<uuid>, and then opens a pool to it with:
const client = new pg.Pool({ ...this.config, database })
When the adapter was built from a connection string, this.config is { connectionString: 'postgresql://user:pass@host/maindb' }. pg merges a connection string over the other config fields when it connects (Object.assign({}, config, parse(config.connectionString)) in pg/lib/connection-parameters.js), so the database named in the URL wins over database. The "shadow" pool therefore connects to maindb, not to the temporary database.
Anything that then runs on the shadow connection, which migrate uses as a scratch database it can reset and replay migrations into, would run on the main database instead. The temporary database is created and dropped but never used.
connectToShadowDb is part of the driver adapter interface used for migrations with driver adapters. Nothing in this repository calls it today, so the reach depends on which tools use the adapter for migrations. Found during review of prisma/orm#29521; that pull request does not touch this code.
Fix: build the shadow pool's config so the temporary database wins, for example by parsing the connection string and replacing its database before creating the pool, and add a unit test that checks the effective database pg would connect to (new pg.Client(pool.options).connectionParameters.database).
- Dominant language
- TypeScript
- Stars
- 47.8k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 227
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from prisma/orm
-
bug/1-unconfirmed kind/bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
get-platform: distros with ID_LIKE=alpine are not detected as musl, so glibc engines are used on Alpine-based imagesPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
prisma/orm#31281 · 1 comment ·
Maintainers usually reply within 1 day
-
[Prisma 8] Type-check time grows exponentially with chained .include() callsPossibly taken @SiKreuz claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
prisma/orm#31161 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
prisma/orm#31125 · 4 comments · 6 reactions ·
Maintainers usually reply within 1 day
-
adapter-better-sqlite3: startTransaction() leaks its mutex when BEGIN throws, every later transaction hangsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
prisma/orm#30881 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
tenstorrent/ttnn-visualizer#2526 ·
Maintainers usually reply within 1 day
-
trySessionCache calls /get-session twice when minting session_data (cache miss or expired cookie)Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
neondatabase/neon-js#301 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tashfeenahmed/freellmapi#2305 ·
Maintainers usually reply within 1 day