Supabase [users.id]

I ran drizzle-kit pull to get my existing schema from Supabase. The schema output included the following
export const notifications = pgTable("notifications", {
id: uuid().defaultRandom().primaryKey().notNull(),
userId: uuid("user_id").notNull(),
createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
body: text().notNull(),
}, (table) => {
return {
notificationsUserIdFkey: foreignKey({
columns: [table.userId],
foreignColumns: [users.id],
name: "notifications_user_id_fkey"
}),
}
});
export const notifications = pgTable("notifications", {
id: uuid().defaultRandom().primaryKey().notNull(),
userId: uuid("user_id").notNull(),
createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
body: text().notNull(),
}, (table) => {
return {
notificationsUserIdFkey: foreignKey({
columns: [table.userId],
foreignColumns: [users.id],
name: "notifications_user_id_fkey"
}),
}
});
The issue was with [users.id]. It said: Cannot find name 'users'.ts(2304). I updated [users.id] to be [authUsers.id]. I also imported:
import {
authenticatedRole,
authUid,
authUsers,
realtimeMessages,
realtimeTopic,
supabaseAuthAdminRole,
} from "drizzle-orm/supabase";
import {
authenticatedRole,
authUid,
authUsers,
realtimeMessages,
realtimeTopic,
supabaseAuthAdminRole,
} from "drizzle-orm/supabase";
Is that correct fix? The error went away, but this is all new to me.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server