mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-06-05 19:15:30 -04:00
refactor: neon -> planetscale
This commit is contained in:
+19
-4
@@ -1,7 +1,22 @@
|
||||
import { env } from "@/lib/env";
|
||||
import { drizzle } from "drizzle-orm/neon-http";
|
||||
import { neon } from "@neondatabase/serverless";
|
||||
import * as schema from "@/lib/db/schema";
|
||||
import { attachDatabasePool } from "@vercel/functions";
|
||||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
import { Pool } from "pg";
|
||||
|
||||
const sql = neon(env.DATABASE_URL);
|
||||
// Create explicit pool instance for better connection management
|
||||
const pool = new Pool({
|
||||
connectionString: env.DATABASE_URL,
|
||||
});
|
||||
|
||||
export const db = drizzle({ client: sql });
|
||||
// Attach to Vercel's pool management to ensure idle connections are properly
|
||||
// released before fluid compute functions suspend:
|
||||
// https://vercel.com/guides/connection-pooling-with-functions
|
||||
try {
|
||||
attachDatabasePool(pool);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
// Pass pool to Drizzle with schema
|
||||
export const db = drizzle(pool, { schema });
|
||||
|
||||
+2
-5
@@ -25,12 +25,9 @@ export const env = createEnv({
|
||||
AUTH_GITHUB_CLIENT_SECRET: z.string().min(1),
|
||||
|
||||
/**
|
||||
* Required. Database connection string for a Postgres database. May be set automatically by Vercel's Neon
|
||||
* integration.
|
||||
*
|
||||
* @see https://vercel.com/integrations/neon
|
||||
* Required. Database connection string for a Postgres database.
|
||||
*/
|
||||
DATABASE_URL: z.string().startsWith("postgres://"),
|
||||
DATABASE_URL: z.string().startsWith("postgresql://"),
|
||||
|
||||
/**
|
||||
* Required. GitHub API token used for [/projects](../app/projects/page.tsx) grid. Only needs the `public_repo`
|
||||
|
||||
Reference in New Issue
Block a user