Trying to migrate a Postgres database from AWS RDS to Vercel for a Nextjs project using Prisma.
When running the db seed command from local machine it completes successfully. As per documentation on vercel, I'm using the specific env variables that were created and recommended for prisma.
datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL") // uses connection pooling
directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
}
The problem arises when attempting to run the seed command from Github actions and I get this nasty error from Prisma:
No pending migrations to apply.
Running seed command `ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts` ...
Connecting to database
An error occurred while running the seed command:
Error: Command was killed with SIGSEGV (Segmentation fault): ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts
Error: Command "npm run vercel-build" exited with 1
Error: Process completed with exit code 1.
When I deploy my project from local machine directly to vercel, I also get a timeout. So it appears that both my lambda function and github action is not able to connect to the new database in Vercel.
Another thing I tried is to use the @vercel/postgres
library during the seed to see if it's a Prisma issue.
console.log(chalk.blue('Connecting to database'));
const client = await db.connect();
console.log(chalk.green('Connected to database'));
const data = await client.sql`select * from "xxx" limit 1`;
console.log('rows', data.rowCount);
This time a little more meaningful:
The database server at `xxx.us-east-1.postgres.vercel-storage.com`:`5432` was reached but timed out.
Please try again.
Please make sure your database server is running at `xxx.us-east-1.postgres.vercel-storage.com`:`5432`.
Context: Timed out trying to acquire a postgres advisory lock (SELECT pg_advisory_lock(72707369)). Elapsed: 10000ms. See https://pris.ly/d/migrate-advisory-locking for details.