© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
4 replies
puffy_tugboat

Raw sql in schema

Hello! I'm trying to reference the supabase auth table as mentioned in the supabase docs (https://supabase.com/docs/guides/auth/managing-user-data):

create table public.profiles (
  id uuid not null references auth.users on delete cascade,
  first_name text,
  last_name text,

  primary key (id)
);
create table public.profiles (
  id uuid not null references auth.users on delete cascade,
  first_name text,
  last_name text,

  primary key (id)
);


Here's what I have:
export const users = pgTable('users', {
  id: sql`uuid not null references auth.users on delete cascade`,
});
export const users = pgTable('users', {
  id: sql`uuid not null references auth.users on delete cascade`,
});


But I guess I'm not doing it correctly as Ts complains:
Type 'SQL<unknown>' is not assignable to type 'PgColumnBuilderBase<ColumnBuilderBaseConfig<ColumnDataType, string>, object>'.
  Types of property '_' are incompatible.
    Type '{ brand: "SQL"; type: unknown; }' is missing the following properties from type '{ brand: "ColumnBuilder"; name: string; dataType: ColumnDataType; columnType: string; data: unknown; driverParam: unknown; notNull: boolean; hasDefault: boolean; enumValues: string[] | undefined; dialect: "pg"; }': name, dataType, columnType, data, and 5 more.ts(2322)
Type 'SQL<unknown>' is not assignable to type 'PgColumnBuilderBase<ColumnBuilderBaseConfig<ColumnDataType, string>, object>'.
  Types of property '_' are incompatible.
    Type '{ brand: "SQL"; type: unknown; }' is missing the following properties from type '{ brand: "ColumnBuilder"; name: string; dataType: ColumnDataType; columnType: string; data: unknown; driverParam: unknown; notNull: boolean; hasDefault: boolean; enumValues: string[] | undefined; dialect: "pg"; }': name, dataType, columnType, data, and 5 more.ts(2322)


I'm aware there are other "solutions" to this problem of referencing the auth table that involve editing the generated SQL afterwards, but would prefer if I could somehow define the raw sql in the schema itself

Thanks in advance
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

raw SQL in schema
Drizzle TeamDTDrizzle Team / help
2y ago
Raw SQL / Postgres stored generated column in schema
Drizzle TeamDTDrizzle Team / help
3y ago
pgTable - raw sql
Drizzle TeamDTDrizzle Team / help
3y ago