postgress migration error
I'm following your instructions for migration (https://www.prisma.io/docs/getting-started/prisma-postgres/upgrade-from-early-access) for Windows.
I set the env variable DATABASE_URL (with SET, export shows an error - set DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=ey..."). Once i set the variable i launch npx @prisma/ppg-tunnel --host 127.0.0.1 --port 5432 i receive the following error
PS C:\Users\MyPC> npx @prisma/ppg-tunnel --host 127.0.0.1 --port 5432
file:///C:/Users/MyPC/AppData/Local/npm-cache/_npx/cdc1c80c7d03f8e1/node_modules/@prisma/ppg-tunnel/dist/index.js:117
throw new Error("No API key found");
^
Error: No API key found
at resolveApiKey (file:///C:/Users/MyPC/AppData/Local/npm-cache/_npx/cdc1c80c7d03f8e1/node_modules/@prisma/ppg-tunnel/dist/index.js:117:15)
at file:///C:/Users/MyPC/AppData/Local/npm-cache/_npx/cdc1c80c7d03f8e1/node_modules/@prisma/ppg-tunnel/dist/index.js:18:17
at ModuleJob.run (node:internal/modules/esm/module_job:271:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)
Node.js v22.13.0
Upgrade Prisma Postgres from Early Access | Prisma Documentation
Upgrade your Prisma Postgres database from Early Access database to General Availability database.
7 Replies
You chose to compile with the bot. One moment while I piece together your answer…
Based on the information provided in the knowledge sources and your question, it appears you're encountering an issue with setting up Prisma Postgres and running migrations on Windows. Let's address the problem step by step:
1. Environment Variable Setup:
On Windows, you should use the
set
command to set environment variables, which you've done correctly. However, the format of your DATABASE_URL seems to be incorrect. According to the Prisma documentation, the correct format should be:
Make sure there are no spaces around the equals sign.
2. API Key Error:
The error message you're receiving suggests that the API key is not being properly recognized. This could be due to a few reasons:
a. The API key might not be correctly set in the DATABASE_URL.
b. The PULSE_API_KEY environment variable might be missing.
According to the documentation, you should have both DATABASE_URL and PULSE_API_KEY set in your environment variables. Try setting the PULSE_API_KEY separately:
Make sure to use the same API key value for both DATABASE_URL and PULSE_API_KEY.
3. Verifying Environment Variables:
To check if your environment variables are set correctly, you can use the echo
command:
This will display the values of these variables, allowing you to verify they are set correctly.
4. Running the Tunnel Command:
After setting the environment variables correctly, try running the tunnel command again:
If you're still encountering issues after following these steps, it might be helpful to double-check your Prisma Data Platform setup and
ensure that you have the correct API key. You may also want to try restarting your command prompt after setting the environment variables to ensure they are properly recognized.
If the problem persists, you might want to reach out to Prisma support for further assistance, as suggested in one of the GitHub issues: Query Fails with Invalid API Key Error Despite Correct .env Setup.now i receive the error
npx @prisma/ppg-tunnel --host 127.0.0.1 --port 5432
node:internal/url:818
href = bindingUrl.parse(input, base, true);
^
TypeError: Invalid URL
at new URL (node:internal/url:818:25)
at resolveApiKey (file:///C:/Users/Marco.Bibiana/AppData/Local/npm-cache/_npx/cdc1c80c7d03f8e1/node_modules/@prisma/ppg-tunnel/dist/index.js:107:21)
at file:///C:/Users/Marco.Bibiana/AppData/Local/npm-cache/_npx/cdc1c80c7d03f8e1/node_modules/@prisma/ppg-tunnel/dist/index.js:18:17
at ModuleJob.run (node:internal/modules/esm/module_job:271:25)
at async onImport.tracePromise.proto (node:internal/modules/esm/loader:547:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) {
code: 'ERR_INVALID_URL',
input: '"prisma+postgres://accelerate.prisma-data.net/?api_key=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcGlfa2V5IjoiODAyOWE1YTMtYTg0Ni00ODBlLTk1NGYtYzQ3NmY5MTE0NGVlIiwidGVuYW50X2lkIjoiN2E2NWIzMzIwNjEyM2VhMTUyYmZkMTU3MmNjYWNmZWRkN2E3ODBmMDFkNDE2ZWI2ODI1NWNlZDQ1ODJlNThlNiIsImludGVybmFsX3NlY3JldCI6IjNmNzYxMGIwLWIxZWEtNDQ1My1hYTQxLWRjZTBiZTM5YjFmYyJ9.8pYF2fhdaQydzMp1P5RhrIKYp5hxGIAUZvIOBVYsMs4"'
}
Node.js v22.13.0
✅ Great, thanks for letting us know that this solved your question!
@Markigno Are you still facing any issues?
instruction for windows are not correct, and i'm trying to translate for it
@Nurul (Prisma)
the point is that error messages are not clear and i'm asking to your ai agent + chatgpt to help me
for example the error "node:internal/url:818
href = bindingUrl.parse(input, base, true);" was due to wrong port number (already used port number)
another point is that to create the new database I need to create a new environment (it is impossible to have 2 dB for 1 env). Not an easy solution...
the dump is not working correctly
instruction for windows are not correct, and i'm trying to translate for itDo you mean the instruction to set environment variable is not correct? Can you share the command that worked for you?
another point is that to create the new database I need to create a new environment (it is impossible to have 2 dB for 1 env). Not an easy solution...You are correct that at the moment, each environment has only one environment. I'll pass along the feedback. Can you let me know why creating a new environment to get a new database does not work for you?
the dump is not working correctlyThanks for sharing the error message. I have reported it to team internally.