fix(seed): make seed-sudan-cities work with Prisma 7.x adapters#33
Merged
Conversation
Two issues needed fixing to actually run the script against the live Neon DB (which is what just produced the 42 listings now in prod): 1. Prisma 7.x rejects 'new PrismaClient()' with no options — it requires either an adapter or accelerateUrl. The fix: import the app's existing 'db' from '@/lib/db', which already wires up PrismaPg / PrismaNeon based on DATABASE_URL_ADAPTER. 2. ES module imports are hoisted and execute in source order. If '@/lib/db' is imported before dotenv runs, its module-level 'createPrismaClient()' reads an empty process.env and can't find DATABASE_URL. Switch to 'import "dotenv/config"' as a side-effect entry — it runs config() at module-load time, so DATABASE_URL is set by the time any other import resolves. Run as: DATABASE_URL_ADAPTER=neon FORCE_SEED=1 pnpm seed:sudan Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this PR exists
PR #23 added the seed script. Running it on this machine against prod hit two issues:
new PrismaClient()— it requires an adapter or accelerateUrl.@/lib/dbis imported and runs its module-levelcreatePrismaClient()beforedotenv.config()runs in the function body, soDATABASE_URLis empty when the adapter is constructed.Fixes
How to run after this lands
(
FORCE_SEED=1overrides theNODE_ENV=productionguard.DATABASE_URL_ADAPTER=neonselects the HTTPS-tunneled Neon driver.)Receipt
The pre-fix-script run that produced this PR's content created 42 listings across 7 Sudanese cities in prod (Khartoum, Omdurman, Bahri, Wad Madani, Atbara, Kassala, Nyala) — the autocomplete now returns city diversity:
🤖 Generated with Claude Code