HELP: Key columns "resource_id" and "id" are of incompatible types: text and integer.

I don't know what to do anymore i've tried all the possible solutions i could think about, export const bookmarks = pgTable("bookmarks", { id: serial("id").primaryKey(), user_id: text("user_id") .notNull() .references(() => users.id), resource_id: text("resource_id") .notNull() .references(() => resource.id), }); export const bookmarkRelations = relations(bookmarks, ({ one }) => ({ resource: one(resource, { fields: [bookmarks.resource_id], references: [resource.id], }), user: one(users, { fields: [bookmarks.user_id], references: [users.id], }), })); export const users = pgTable("user", { id: text("id").notNull().primaryKey(), name: text("name"), email: text("email").notNull(), emailVerified: timestamp("emailVerified", { mode: "date" }), image: text("image"), }); export const userRelations = relations(users, ({ many }) => ({ sharedLinks: many(sharedLinks), bookmarks: many(bookmarks), }));
1 Reply
Angelelz
Angelelz17mo ago
Serial is an alias for unsigned int. Drizzle currently doesn't support unsigned. I'd suggest changing your id to int on both sides so they match

Did you find this page helpful?