Vercel error when using both PlanetScale and Postgres in the same Next app

I'm using two separate databases for my app. The PlanetScale one is the "main" database, and the Postgres is a self-hosted database. I have separate Drizzle instances and schemas for both. PlanetScale:
// @/lib/server/db/index.ts
import { drizzle } from "drizzle-orm/planetscale-serverless";
import { connect } from "@planetscale/database";
import { env } from "@/env.mjs";
import * as schema from "./schema";

const connection = connect({
host: env.DATABASE_HOST,
username: env.DATABASE_USERNAME,
password: env.DATABASE_PASSWORD,
});

export const db = drizzle(connection, { schema });
// @/lib/server/db/index.ts
import { drizzle } from "drizzle-orm/planetscale-serverless";
import { connect } from "@planetscale/database";
import { env } from "@/env.mjs";
import * as schema from "./schema";

const connection = connect({
host: env.DATABASE_HOST,
username: env.DATABASE_USERNAME,
password: env.DATABASE_PASSWORD,
});

export const db = drizzle(connection, { schema });
Postgres:
// @/lib/server/db/indexer/index.ts
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as schema from "./schema";
import { env } from "@/env.mjs";

const client = postgres({
host: env.INDEXER_DB_HOST,
username: env.INDEXER_DB_USERNAME,
password: env.INDEXER_DB_PASSWORD,
port: env.INDEXER_DB_PORT,
database: env.INDEXER_DB_NAME,
});

export const indexer = drizzle(client, { schema });
// @/lib/server/db/indexer/index.ts
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as schema from "./schema";
import { env } from "@/env.mjs";

const client = postgres({
host: env.INDEXER_DB_HOST,
username: env.INDEXER_DB_USERNAME,
password: env.INDEXER_DB_PASSWORD,
port: env.INDEXER_DB_PORT,
database: env.INDEXER_DB_NAME,
});

export const indexer = drizzle(client, { schema });
Other than needing to switch pages that use the pg connection over to nodejs instead of edge, this works well locally. I've just tried to deploy to Vercel and I'm getting this error:
./src/lib/server/db/indexer/schema.ts + 55 modules
Cannot get final name for export 'PgColumn' of ./node_modules/.pnpm/drizzle-orm@0.29.0_@planetscale+database@1.11.0_postgres@3.4.3/node_modules/drizzle-orm/pg-core/columns/index.js
./src/lib/server/db/indexer/schema.ts + 55 modules
Cannot get final name for export 'PgColumn' of ./node_modules/.pnpm/drizzle-orm@0.29.0_@planetscale+database@1.11.0_postgres@3.4.3/node_modules/drizzle-orm/pg-core/columns/index.js
I'm thinking I should just load up the pg HTTP proxy on my server and use that but I'd rather not add another layer of complexity here.
1 Reply
Kairu
Kairu10mo ago
Switching from postgres to pg results in much the same error:
Cannot get final name for export 'PgColumn' of ./node_modules/.pnpm/drizzle-orm@0.29.0_@planetscale+database@1.11.0_@types+pg@8.10.9_pg@8.11.3/node_modules/drizzle-orm/pg-core/columns/index.js
Cannot get final name for export 'PgColumn' of ./node_modules/.pnpm/drizzle-orm@0.29.0_@planetscale+database@1.11.0_@types+pg@8.10.9_pg@8.11.3/node_modules/drizzle-orm/pg-core/columns/index.js
I think an unrelated type error may have caused this, as fixing that fixed this. somehow..
Want results from more Discord servers?
Add your server