Using Planetscale has been very confusing until now, but I think I managed to cut through quite a lot to get to this last issue:
My function can’t connect to the test branch on PlanetScale. I have defined all env variables and am using WithPlanetScale, but it tries to run my queries again my production/main DB. I can re-factor to use DATABASE_URL but am thinking if I can get the context thing to work, that would save me effort and over time also set the base for a cleaner and more secure/stable code.
I got all env .variables set for the right DB contexts on Netlify and followed all integration steps (I connect to the DB and try and run queries…).
Is this a known issue? If so, is there a solution or at least a workaround?
Changing to planetscale/database connect, as well as changing all credentials to test DB credentials in the env variables helped. If someone got context to really work, would be cool to know how. I actually don’t think it works or that I understand it enough.
Great. Would love to get some feedback. I’m new to React/Netlify/Planetscale so will be awesome to learn more. Please also explain context, preferably with a couple of examples how it should work in a dev/test-prod setup.
Now, it was intended to be used in tandem with the UI documented here. However, there is no reason you can’t have these 3 environment variables set manually and use the withPlanetscale.
Is the test database you’re trying to connect to a branch on Planetscale, or is it it’s own separate database?