schemaFilter not working as expected

I've got this on my drizzle.config.ts:
schemaFilter: "public",
schemaFilter: "public",
And this is my schema.ts:
import { InferSelectModel } from "drizzle-orm";
import {
bigint,
boolean,
jsonb,
pgSchema,
pgTable,
text,
timestamp,
} from "drizzle-orm/pg-core";

export const todos = pgTable(
"todos",
{
id: bigint("id", { mode: "bigint" })
.primaryKey()
.generatedByDefaultAsIdentity(),
userId: text("user_id")
.notNull(),
task: text("task").notNull(),
isComplete: boolean("is_complete").notNull().default(false),
insertedAt: timestamp("inserted_at", { withTimezone: true })
.defaultNow()
.notNull(),
},
);

// Filter out the neon_identity schema in `drizzle.config.ts` in order to NOT generate the schema for it.
export const neonIdentitySchema = pgSchema("neon_identity");

export const users = neonIdentitySchema.table("users_sync", {
rawJson: jsonb("raw_json").notNull(),
id: text().primaryKey().notNull(),
name: text(),
email: text(),
createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }),
deletedAt: timestamp("deleted_at", { withTimezone: true, mode: 'string' }),
});

export type Todo = InferSelectModel<typeof todos>;
import { InferSelectModel } from "drizzle-orm";
import {
bigint,
boolean,
jsonb,
pgSchema,
pgTable,
text,
timestamp,
} from "drizzle-orm/pg-core";

export const todos = pgTable(
"todos",
{
id: bigint("id", { mode: "bigint" })
.primaryKey()
.generatedByDefaultAsIdentity(),
userId: text("user_id")
.notNull(),
task: text("task").notNull(),
isComplete: boolean("is_complete").notNull().default(false),
insertedAt: timestamp("inserted_at", { withTimezone: true })
.defaultNow()
.notNull(),
},
);

// Filter out the neon_identity schema in `drizzle.config.ts` in order to NOT generate the schema for it.
export const neonIdentitySchema = pgSchema("neon_identity");

export const users = neonIdentitySchema.table("users_sync", {
rawJson: jsonb("raw_json").notNull(),
id: text().primaryKey().notNull(),
name: text(),
email: text(),
createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }),
deletedAt: timestamp("deleted_at", { withTimezone: true, mode: 'string' }),
});

export type Todo = InferSelectModel<typeof todos>;
When I run drizzle-kit generate, for some reason I still get:
CREATE SCHEMA "neon_identity";
...
CREATE TABLE "neon_identity"."users_sync" (
...
CREATE SCHEMA "neon_identity";
...
CREATE TABLE "neon_identity"."users_sync" (
...
So, the schemaFilter is not working... It's still trying to generate the neon_identity schema which it should be skipping. This is on the latest drizzle-kit, btw, 0.30.1.
2 Replies
TOSL
TOSL5d ago
Only works for push and pull commands
David Gomes
David GomesOP4d ago
Oh, interesting. Is there a workaround?

Did you find this page helpful?