try to push : schema "XXX" does not exist

When I try to add a custom schema, the push command dont works :
export const quizSchema = pgSchema("quiz");

export const answerTypeEnum = quizSchema.enum("answer_type", ["single_choice", "multiple_choice", "boolean", "text", "number"]);

export const quizzes = quizSchema.table("quizzes", {
id: integer().primaryKey().generatedByDefaultAsIdentity(),
title: text("title").notNull(),
iso_3166_1: varchar({ length: 2 }) // can be null, if provided, means the quiz is country-specific
}, (table) => [
index("quizzes_iso_3166_1_index").on(table.iso_3166_1)
]);
export const quizSchema = pgSchema("quiz");

export const answerTypeEnum = quizSchema.enum("answer_type", ["single_choice", "multiple_choice", "boolean", "text", "number"]);

export const quizzes = quizSchema.table("quizzes", {
id: integer().primaryKey().generatedByDefaultAsIdentity(),
title: text("title").notNull(),
iso_3166_1: varchar({ length: 2 }) // can be null, if provided, means the quiz is country-specific
}, (table) => [
index("quizzes_iso_3166_1_index").on(table.iso_3166_1)
]);
I have this error :
$ drizzle-kit push
No config path provided, using default 'drizzle.config.ts'
Reading config file '/project/drizzle.config.ts'
Using 'pg' driver for database querying
[✓] Pulling schema from database...
error: schema "quiz" does not exist
$ drizzle-kit push
No config path provided, using default 'drizzle.config.ts'
Reading config file '/project/drizzle.config.ts'
Using 'pg' driver for database querying
[✓] Pulling schema from database...
error: schema "quiz" does not exist
any idea ?
Solution:
okay ive found. I had to add schemaFilter: ['public', 'quiz'], in the drizzle.config.ts file
Jump to solution
2 Replies
Solution
loup
loup7d ago
okay ive found. I had to add schemaFilter: ['public', 'quiz'], in the drizzle.config.ts file
nu
nu7d ago
I may be wrong but I think push doesn't create new schema, only uses it. You either have to create it separately or maybe use drizzle-kit generate and then migrate (provided you see the CREATE SCHEMA line in generated migrations). Oops didn't see your response ahaha

Did you find this page helpful?