Hello! Really loving the workflow and productivity of RedwoodJS. Thanks to all who develop and maintain! I have a specific problem that happens a little too often and I’ve finally reached my breaking point resulting in a new post here.
yarn rw dev running, it appears file changes in the
/api directory sometimes will basically wipe my database. Tables and columns still exist, but all the rows are gone in every table.
Here is a loom demo: Loom | Free Screen & Video Recording Software | Loom
Aha! So this is related specifically to running postgres on vercel. If you follow the standard setup, you are given env variables like
POSTGRES_PRISMA_URL for your database url. I made the mistake of changing the
DATABASE_URL reference in
The RedwoodJS test helper overrides
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb
You can’t edit the auto-generated vercel postgres env vars, so I added
DATABASE_URL_NON_POOLING manually, just pointing to the same auto-generated values for
The reason this was happening on save was actually from the Jest extension was auto running the test, causing
yarn rw prisma db push to get called, which was hitting my dev database because the schema pointed to
POSTGRES_PRISMA_URL which the RedwoodJS testing utils obviously don’t override.
I’ll leave this up for searchability in case anyone else stumbles into this. Thanks for the rubber duck!