Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Teamβ€’2y agoβ€’
13 replies
LuukOriginal

Drizzle-zod typeerror when passing in pgtable

I keep getting a type error when trying to get the zod schema from the pg schema with drizzle: public.ts
import { pgTable, timestamp, serial, text, pgEnum } from 'drizzle-orm/pg-core'

export const TeamSubscriptionTier = pgEnum('team_subscription_tier', ['basic', 'team', 'enterprise']);

export const teams = pgTable('teams', {
  /**
   * The auto-incrementing ID of the team.
   */
  id: serial('team_id').primaryKey(),

  /**
   * The timestamp when the team was created.
   */
  created_at: timestamp('created_at', { withTimezone: false }).defaultNow().notNull(),

  /**
   * The name of the team.
   */
  name: text('name').notNull(),

  /**
   * The description of the team.
   */
  description: text('description'),

  /**
   * The subscription tier of the team.
   */
  subcription_tier: TeamSubscriptionTier('subscription_tier')
});
import { pgTable, timestamp, serial, text, pgEnum } from 'drizzle-orm/pg-core'

export const TeamSubscriptionTier = pgEnum('team_subscription_tier', ['basic', 'team', 'enterprise']);

export const teams = pgTable('teams', {
  /**
   * The auto-incrementing ID of the team.
   */
  id: serial('team_id').primaryKey(),

  /**
   * The timestamp when the team was created.
   */
  created_at: timestamp('created_at', { withTimezone: false }).defaultNow().notNull(),

  /**
   * The name of the team.
   */
  name: text('name').notNull(),

  /**
   * The description of the team.
   */
  description: text('description'),

  /**
   * The subscription tier of the team.
   */
  subcription_tier: TeamSubscriptionTier('subscription_tier')
});
contract.ts
import { initContract } from '@ts-rest/core';
import { z } from 'zod';
import { ErrorResponseSchema } from '@bloxgrid/common/dist/schemas/error-response.schema'
import { teams } from '@bloxgrid/common/src/database/schema/public'
import { createSelectSchema } from 'drizzle-zod'

const c = initContract();

export const teamsContract = c.router({
    getTeams: {
        method: 'GET',
        path: '/',
        query: z.object({
            name: z.string().optional(),
        }),
        responses: {
            200: createSelectSchema(teams), //teams here is giving the type error
            400: ErrorResponseSchema
        },
        summary: 'Get a list of teams',
    }
}, {
    pathPrefix: '/teams' as const
});
import { initContract } from '@ts-rest/core';
import { z } from 'zod';
import { ErrorResponseSchema } from '@bloxgrid/common/dist/schemas/error-response.schema'
import { teams } from '@bloxgrid/common/src/database/schema/public'
import { createSelectSchema } from 'drizzle-zod'

const c = initContract();

export const teamsContract = c.router({
    getTeams: {
        method: 'GET',
        path: '/',
        query: z.object({
            name: z.string().optional(),
        }),
        responses: {
            200: createSelectSchema(teams), //teams here is giving the type error
            400: ErrorResponseSchema
        },
        summary: 'Get a list of teams',
    }
}, {
    pathPrefix: '/teams' as const
});
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Drizzle-Zod
Drizzle TeamDTDrizzle Team / help
9mo ago
Drizzle-zod errors
Drizzle TeamDTDrizzle Team / help
2y ago
drizzle-zod failing
Drizzle TeamDTDrizzle Team / help
3y ago
Type issue PgTableWithColumns incompatible with PgTable<TableConfig>
Drizzle TeamDTDrizzle Team / help
15mo ago