Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vercel Postgres is now only available through Neon Marketplace integration if you don't have an existing Vercel Postgres store. #610

Open
JCAdkins opened this issue Dec 11, 2024 · 3 comments

Comments

@JCAdkins
Copy link

Pretty much what the title states as of December 2024. You may want to update the README to help people set up the project with integration through Neon Database.

At https://vercel.com/marketplace/neon, you will need to click install where you will be able to select a Vercel team to install Neon Database. Select the region you want and options you want, then continue and name it whatever you want. Once created it'll give you all your .env.local secrets and can connect it with your project.

You will need to install @neondatabase/serverless in the project.

Then, the following db.ts file needs to be created somewhere, maybe the root of the project, or you can add it directly to the /lib/db/migrate.ts file.

// src/db.ts
import { drizzle } from "drizzle-orm/neon-http";
import { neon } from "@neondatabase/serverless";
import { config } from "dotenv";

config({ path: ".env.local" }); // or .env.local

const sql = neon(process.env.DATABASE_URL!);
export const db = drizzle(sql);

Then in /lib/db/migrate.ts, you need to import { db } from '@/db' (obviously don't need to do this if you put the above right in the file).

Next, change import { migrate } from 'drizzle-orm/postgres-js/migrator to import { migrate } from 'drizzle-orm/neon-http/migrator.

Finally, comment out or delete the lines

const connection = postgres(process.env.POSTGRES_URL, { max: 1 });
const db = drizzle(connection);

Definitely other ways to do it, this is just how I did it.

@essamsleiman
Copy link

Hey are these all the steps? After taking these steps, i'm not able to login or signup from localhost, and it gives me the following error:

Failed to get user from database [auth][error] CallbackRouteError: Read more at https://errors.authjs.dev#callbackrouteerror [auth][cause]: PostgresError: relation "User" does not exist at ErrorResponse (/Users/essamsleiman/Desktop/DesktopFolder/Startup/canvas-org/canvas-copilot/.next/server/chunks/ssr/node_modules__pnpm_6e480e._.js:2529:224) at handle (/Users/essamsleiman/Desktop/DesktopFolder/Startup/canvas-org/canvas-copilot/.next/server/chunks/ssr/node_modules__pnpm_6e480e._.js:2329:728) at TLSSocket.data (/Users/essamsleiman/Desktop/DesktopFolder/Startup/canvas-org/canvas-copilot/.next/server/chunks/ssr/node_modules__pnpm_6e480e._.js:2217:17) at TLSSocket.emit (node:events:518:28) at addChunk (node:internal/streams/readable:559:12) at readableAddChunkPushByteMode (node:internal/streams/readable:510:3) at Readable.push (node:internal/streams/readable:390:5) at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23) at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) [auth][details]: { "provider": "credentials"

@JCAdkins
Copy link
Author

JCAdkins commented Dec 11, 2024

Did you run db:generate and db:migrate scripts after putting in the neon database? db:generate will generate the sql scripts and db:migrate should move it into your db. Then you should be able to successfully create an account.

@dancomanlive
Copy link

Only need pnpm run db:migrate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants