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
raaden11mo 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 Sherman11mo 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
raaden11mo 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 Sherman11mo ago
Try to remove all node_modules and just reinstall it may fix your issue
West side ⁉
West side ⁉10mo 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 ⁉10mo 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 ⁉10mo 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 ⁉10mo ago
No description
West side ⁉
West side ⁉10mo ago
bun install pg and you're (partially) good to go 👍
West side ⁉
West side ⁉10mo ago
fuck
No description
West side ⁉
West side ⁉10mo ago
kids, don't forget to run your migrations!
West side ⁉
West side ⁉10mo ago
this is so consuming I need some help Error [PostgresError]: unrecognized configuration parameter "schema"
No description
West side ⁉
West side ⁉10mo 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
More Posts
Does throwing a regular javascript error inside a transaction, roll back automatically?Curious if I need to actually call tx.rollback()? Or if we reach a regular error, or lets say a PostDrizzle join in a subquery results in ambiguous columnsThis fails with `id ambiguous` error, since the `orderedQuestions.survey_question.id` reference in tSchema Definition Performance / Best PracticeIs it considered bad practice to have one massive client / schema definition for my whole project thIs there a recommended way to find or create a record? (postgres)I don't want to do an insert with `ON CONFLICT RETURNING` since I have triggers which fire on row upGet plain typescript type from enumHi, I am working on a NestJS + Drizzle app and I have the following in my schema: ```ts export constCan't build app due to missing dependencies with DrizzleHello y'all, very new to drizzle and while trying to use the quick start guide I ran into the errorsWhy does JSON configuration for drizzle-kit not require a dbCredentials?Hello, according to https://orm.drizzle.team/kit-docs/overview#configuration. For both JS & TS of thWhat's the correct type to use for an update function?I'm trying to do a simple function where I update a record in a table: ```ts import { NewVideo, VidStudio with AWS Data API?Is it possible to use Drizzle Studio with the AWS Data API, seeing as it doesn't have a true connectDeferrable foreign key constraintsHi, does anyone know a way to declare deferrable foreign key constraints when defining a Postgres ta