N
Neon3mo ago
rival-black

all logs show success but db on neon does not update.

i. am. so. done. with. this. I have a db which has a table called users, when i login with clerk, it makes a user. after login, the website takes the user to /onboarding where the user has to enter additional information like phone number, postcode and "about me." on submit, the db should be updated with the new details, for the same user, on the same users table. but it is not happening. I have taken logs from the frontend and the backend with all returning status 200 with all the right details in json format. the db connection is working as well, checked with a simple GET API route and by running pnpm prisma studio. The status 200 logs:
Server: User ID from Clerk session (currentUser): user_2zPQd2ZhtqDzxIU7NU2s45utyRs
Server: User ID from form data (validatedData): {
firstName: 'Lama',
lastName: 'Baioi',
postcode: 'BL1 3BH',
email: 'mansoor.eb@gmail.com',
phoneNumber: '0753791889',
aboutMe: 'FIRST NAME LAST NAME'
}
Server: Attempting to update DB for ID: user_2zPQd2ZhtqDzxIU7NU2s45utyRs
prisma:query SELECT 1
prisma:query UPDATE "public"."User" SET "firstName" = $1, "lastName" = $2, "postcode" = $3, "email" = $4, "phoneNumber" = $5, "aboutMe" = $6, "updatedAt" = $7 WHERE ("public"."User"."id" = $8 AND 1=1) RETURNING "public"."User"."id", "public"."User"."name", "public"."User"."firstName", "public"."User"."lastName", "public"."User"."postcode", "public"."User"."avatar", "public"."User"."email", "public"."User"."phoneNumber", "public"."User"."aboutMe", "public"."User"."createdAt", "public"."User"."updatedAt"
Server: Successfully updated DB user record with ID: user_2zPQd2ZhtqDzxIU7NU2s45utyRs
Server: Clerk publicMetadata updated for user: user_2zPQd2ZhtqDzxIU7NU2s45utyRs
PUT /api/onboarding 200 in 1074ms
GET / 200 in 152ms
Server: User ID from Clerk session (currentUser): user_2zPQd2ZhtqDzxIU7NU2s45utyRs
Server: User ID from form data (validatedData): {
firstName: 'Lama',
lastName: 'Baioi',
postcode: 'BL1 3BH',
email: 'mansoor.eb@gmail.com',
phoneNumber: '0753791889',
aboutMe: 'FIRST NAME LAST NAME'
}
Server: Attempting to update DB for ID: user_2zPQd2ZhtqDzxIU7NU2s45utyRs
prisma:query SELECT 1
prisma:query UPDATE "public"."User" SET "firstName" = $1, "lastName" = $2, "postcode" = $3, "email" = $4, "phoneNumber" = $5, "aboutMe" = $6, "updatedAt" = $7 WHERE ("public"."User"."id" = $8 AND 1=1) RETURNING "public"."User"."id", "public"."User"."name", "public"."User"."firstName", "public"."User"."lastName", "public"."User"."postcode", "public"."User"."avatar", "public"."User"."email", "public"."User"."phoneNumber", "public"."User"."aboutMe", "public"."User"."createdAt", "public"."User"."updatedAt"
Server: Successfully updated DB user record with ID: user_2zPQd2ZhtqDzxIU7NU2s45utyRs
Server: Clerk publicMetadata updated for user: user_2zPQd2ZhtqDzxIU7NU2s45utyRs
PUT /api/onboarding 200 in 1074ms
GET / 200 in 152ms
4 Replies
rival-black
rival-blackOP3mo ago
other things i have tried: - nuking the db and adding tables again - updating tables with postman (works) @Ask Inkeep
Ask Inkeep
Ask Inkeep3mo ago
Thanks for tagging me @xyzmani. I'll look through relevant sources and get back to you shortly. Answer Based on your logs, the database update is actually working successfully - the Prisma query is executing and returning the updated record (1) . This appears to be a caching issue similar to what was discussed in a previous case . The issue is likely Next.js caching your API routes or data fetching. Try adding this to your API route:
export const dynamic = 'force-dynamic'
export const dynamic = 'force-dynamic'
This forces Next.js to always perform a fresh query against the database instead of serving cached responses . The previous user had the exact same symptoms - updates were working in the database but not reflected in the application - and this solution resolved it . Since your Postman updates work and the Prisma logs show successful updates, this confirms it's a Next.js caching issue rather than a database problem . ​ To learn more, see the sources I considered: [1] Can't get updated data after update data in production ​ Feel free to tag @Ask Inkeep with additional questions.
rival-black
rival-blackOP3mo ago
the issue isn't that the app is showing old data, but the db itself not updating despite the logs showing that the db is connected and the app is sending the right data to the db @Ask Inkeep
Ask Inkeep
Ask Inkeep3mo ago
Thanks for the follow-up, @xyzmani. I'll get back to you soon. Answer Based on your logs, the Prisma UPDATE query is executing successfully and returning the expected fields (1) . However, if the database itself isn't reflecting the changes despite successful logs, here are some troubleshooting steps: 1. Verify the data in Neon directly - Check the actual data in your Neon database using the Neon SQL Editor or psql to confirm whether the update is persisting (2) . 2. Test with a simplified approach - Try using a direct PostgreSQL connection to isolate whether this is a Prisma-specific issue :
const { Pool } = require('pg') ;
require('dotenv') .config() ;

// Replace these values with your PostgreSQL connection details

const connectionString = process.env.DATABASE_URL;
const pool = new Pool({ connectionString }) ;

// Create a table
async function createTable() {
const client = await pool.connect() ;
try {
await client.query(`
CREATE TABLE IF NOT EXISTS example_table (
id SERIAL PRIMARY KEY,
name VARCHAR(100) ,
age INT
) ;
`) ;
console.log('Table created successfully') ;
} finally {
client.release() ;
}
}

// Insert some records
async function insertRecords() {
const client = await pool.connect() ;
try {
const insertQuery = `
INSERT INTO example_table (name, age)
VALUES ($1, $2) , ($3, $4) ;
`;
const values = ['John Doe', 25, 'Jane Doe', 30];
await client.query(insertQuery, values) ;
console.log('Records inserted successfully') ;
} finally {
client.release() ;
}
}

// Connect to PostgreSQL and execute operations
async function main() {
try {
await createTable() ;
await insertRecords() ;
} catch (error) {
console.error('Error:', error) ;
} finally {
// Close the database connection pool
await pool.end() ;
}
}

// Run the main function
main() ;
const { Pool } = require('pg') ;
require('dotenv') .config() ;

// Replace these values with your PostgreSQL connection details

const connectionString = process.env.DATABASE_URL;
const pool = new Pool({ connectionString }) ;

// Create a table
async function createTable() {
const client = await pool.connect() ;
try {
await client.query(`
CREATE TABLE IF NOT EXISTS example_table (
id SERIAL PRIMARY KEY,
name VARCHAR(100) ,
age INT
) ;
`) ;
console.log('Table created successfully') ;
} finally {
client.release() ;
}
}

// Insert some records
async function insertRecords() {
const client = await pool.connect() ;
try {
const insertQuery = `
INSERT INTO example_table (name, age)
VALUES ($1, $2) , ($3, $4) ;
`;
const values = ['John Doe', 25, 'Jane Doe', 30];
await client.query(insertQuery, values) ;
console.log('Records inserted successfully') ;
} finally {
client.release() ;
}
}

// Connect to PostgreSQL and execute operations
async function main() {
try {
await createTable() ;
await insertRecords() ;
} catch (error) {
console.error('Error:', error) ;
} finally {
// Close the database connection pool
await pool.end() ;
}
}

// Run the main function
main() ;
3. Check for transaction rollbacks - Even though your logs show success, ensure there are no silent transaction rollbacks occurring after the update. Since your Postman updates work correctly (1) , this suggests the issue might be in how your application is handling the database transaction or connection pooling. If you're still seeing the same behavior, click the "Ask for help" button to tag a team member for further investigation. ​ To learn more, see the sources I considered: [1] all logs show success but db on neon does not update. [2] Can't get updated data after update data in production ​ Feel free to tag @Ask Inkeep with additional questions.

Did you find this page helpful?