Reputation: 1734
I've tried to specify the schema in my connection string dbCredentials: { connectionString: "postgresql://postgres:pwd@localhost:5432/drizzle?schema=manytomany"}
,but it does not work. So I've tried using schemaFilter
but I found that my schema got deleted instead.
import type { Config
} from "drizzle-kit";
export default {
schema: "./src/db/schemas/schema.m2m.ts",
out: "./drizzle",
driver: 'pg',
dbCredentials: { connectionString: "postgresql://postgres:pwd@localhost:5432/drizzle"},
schemaFilter: 'manytomany',
verbose:true
} satisfies Config;
Result:
Warning You are about to execute current statements:
DROP SCHEMA "manytomany";
What is the correct way to connect to the non-public schema using drizzle and postgres ?
Thanks.
Upvotes: 6
Views: 1862
Reputation: 9483
I don't think you specify the schema in the connectionString, rather in the schema definition, you specify which schema the tables are in. Drizzle then handles it from there.
export const mySchema = pgSchema("my_schema");
export const mySchemaUsers = mySchema.table('users', {
id: serial('id').primaryKey(),
name: text('name'),
});
Upvotes: 1
Reputation: 1
I face the same issue! To whoever is using Drizzle, please set the "strict" and "verbose" tags to true BEFORE you push.
Still looking for solutions..
Upvotes: -2