PostgresError: unrecognized configuration parameter "schema" when creating client for postgres-js

Getting the error when I add schema to the call drizzle(client, {schema}) using version "drizzle-orm": "^0.28.5", "postgres": "^3.3.5", Error goes away when schema is removed.
import { drizzle, type PostgresJsDatabase } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
const queryClient = postgres(process.env.DATABASE_URL, { max: 10 });
export const dbClient: PostgresJsDatabase<typeof dbSchema> = drizzle(queryClient, { schema: dbSchema });
import { drizzle, type PostgresJsDatabase } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
const queryClient = postgres(process.env.DATABASE_URL, { max: 10 });
export const dbClient: PostgresJsDatabase<typeof dbSchema> = drizzle(queryClient, { schema: dbSchema });
Appreciate any help.
13 Replies
raaden
raadenOP15mo ago
If it helps... modifying same code to node-postgres works fine.
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';

export const pool = new Pool({
connectionString: appEnv.DATABASE_URL,
});

export const dbClient = drizzle(pool, { schema: dbSchema });
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';

export const pool = new Pool({
connectionString: appEnv.DATABASE_URL,
});

export const dbClient = drizzle(pool, { schema: dbSchema });
Andrii Sherman
Andrii Sherman15mo ago
checking that now I can see the schema in types. and it's working well on my side if you can share some repo example, I'll try to reproduce it and help
raaden
raadenOP15mo ago
If I am reading the error correctly Postgres is not wanting the schema parameter in there.
I made a minimal repo with the exact same code and it is working fine, so it must be an issue somewhere else that is causing a posgres library conflict? Not sure, but I'm going to try to rebuild the client from scratch and see if it clears. Thanks for the reply and will let you know if I still have an issue.
Andrii Sherman
Andrii Sherman15mo ago
Try to remove all node_modules and just reinstall it may fix your issue
West side ⁉
West side ⁉15mo ago
Having this issue rn, will try and be back
Diagnostics:
1. Type 'PostgresJsDatabase<typeof import("/mnt/projects/coding/js/scholix/src/server/db/schema")>' is not assignable to type 'PostgresJsDatabase'.
The types of '_.schema' are incompatible between these types.
Type 'ExtractTablesWithRelations<typeof import("/mnt/projects/coding/js/scholix/src/server/db/schema")> | undefined' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>> | undefined'.
Type 'ExtractTablesWithRelations<typeof import("/mnt/projects/coding/js/scholix/src/server/db/schema")>' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>>'.
Diagnostics:
1. Type 'PostgresJsDatabase<typeof import("/mnt/projects/coding/js/scholix/src/server/db/schema")>' is not assignable to type 'PostgresJsDatabase'.
The types of '_.schema' are incompatible between these types.
Type 'ExtractTablesWithRelations<typeof import("/mnt/projects/coding/js/scholix/src/server/db/schema")> | undefined' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>> | undefined'.
Type 'ExtractTablesWithRelations<typeof import("/mnt/projects/coding/js/scholix/src/server/db/schema")>' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>>'.
Property 'user' is incompatible with index signature.
Type '{ tsName: "user"; dbName: "user"; columns: { id: PgColumn<{ name: "id"; tableName: "user"; dataType: "number"; columnType: "PgSerial"; data: number; driverParam: number; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>; username: PgColumn<...>; password: PgColumn<...>; createdAt:...' is not assignable to type '{ tsName: string; dbName: never; columns: never; relations: Record<string, Relation<string>>; primaryKey: AnyColumn[]; }'.
Types of property 'dbName' are incompatible.
Type 'string' is not assignable to type 'never'. [2322]
Property 'user' is incompatible with index signature.
Type '{ tsName: "user"; dbName: "user"; columns: { id: PgColumn<{ name: "id"; tableName: "user"; dataType: "number"; columnType: "PgSerial"; data: number; driverParam: number; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>; username: PgColumn<...>; password: PgColumn<...>; createdAt:...' is not assignable to type '{ tsName: string; dbName: never; columns: never; relations: Record<string, Relation<string>>; primaryKey: AnyColumn[]; }'.
Types of property 'dbName' are incompatible.
Type 'string' is not assignable to type 'never'. [2322]
Second block seems to be where the issue be (the 2 blocks are 1 diagnostic)
West side ⁉
West side ⁉15mo ago
GitHub
[BUG]: PgTransaction Type with ExtractTablesWithRelations errors in...
What version of drizzle-orm are you using? 0.28.0 What version of drizzle-kit are you using? 0.19.12 Describe the Bug When using .array() within a postgres schema, the PgTransaction type with Extra...
West side ⁉
West side ⁉15mo ago
I don't know why it's bitching about dbName being a string evne though I never set it but switching to node-postgres solved it for me I won't just give up yet I'll give it a retry once I finish building this damn ting Update: still complaining with node-postgres, although differently
West side ⁉
West side ⁉15mo ago
No description
West side ⁉
West side ⁉15mo ago
bun install pg and you're (partially) good to go 👍
West side ⁉
West side ⁉15mo ago
fuck
No description
West side ⁉
West side ⁉15mo ago
kids, don't forget to run your migrations!
West side ⁉
West side ⁉15mo ago
this is so consuming I need some help Error [PostgresError]: unrecognized configuration parameter "schema"
No description
West side ⁉
West side ⁉15mo ago
Thanks to this individual https://canary.discord.com/channels/1043890932593987624/1110524988164943994/1137736511991857283 who shared his solution discord is truly amazing, being able to search messages and find what others have tried is really helpful I basically had to add ?search_path=public to the DATABASE_URL
Want results from more Discord servers?
Add your server