drizzle-kit push ignores SQL schema

I'm trying to create a Postgres schema using the method mentioned in https://orm.drizzle.team/docs/schemas, but when I run drizzle-kit push, nothing is added to the database. It works fine when I just use pgTable to declare the tables, and drizzle-kit generate creates the Postgres schemas as well. My current src/schemas/auth.ts file looks like this:
import { boolean, pgSchema, text, timestamp } from 'drizzle-orm/pg-core'

export const authSchema = pgSchema('auth')

export const users = authSchema.table('users', {
id: text('id').primaryKey(),
name: text('name').notNull(),
email: text('email').notNull().unique(),
emailVerified: boolean('email_verified')
.$defaultFn(() => false)
.notNull(),
image: text('image'),
createdAt: timestamp('created_at')
.$defaultFn(() => /* @__PURE__ */ new Date())
.notNull(),
updatedAt: timestamp('updated_at')
.$defaultFn(() => /* @__PURE__ */ new Date())
.notNull(),
})
import { boolean, pgSchema, text, timestamp } from 'drizzle-orm/pg-core'

export const authSchema = pgSchema('auth')

export const users = authSchema.table('users', {
id: text('id').primaryKey(),
name: text('name').notNull(),
email: text('email').notNull().unique(),
emailVerified: boolean('email_verified')
.$defaultFn(() => false)
.notNull(),
image: text('image'),
createdAt: timestamp('created_at')
.$defaultFn(() => /* @__PURE__ */ new Date())
.notNull(),
updatedAt: timestamp('updated_at')
.$defaultFn(() => /* @__PURE__ */ new Date())
.notNull(),
})
and my drizzle.config.ts looks like this:
import { defineConfig } from 'drizzle-kit'
import { requireEnv } from 'env'

export default defineConfig({
dialect: 'postgresql',
schema: 'src/schemas',
out: 'drizzle',
dbCredentials: {
url: requireEnv('POSTGRES_URL'),
},
})
import { defineConfig } from 'drizzle-kit'
import { requireEnv } from 'env'

export default defineConfig({
dialect: 'postgresql',
schema: 'src/schemas',
out: 'drizzle',
dbCredentials: {
url: requireEnv('POSTGRES_URL'),
},
})
1 Reply
araguma
aragumaOP4mo ago
nvm, i had to add schemaFilter to the config

Did you find this page helpful?