many-to-many foreign key constraint 787 issue

I cannot add a row in my likes_to_questions table even though both user_id and question_id are unique, and the primary key is composed of those two, so as to allow a user to have only 1 like on a question

this is my relations

// 📃 LIKES TO QUESTIONS

export const likesToQuestionsTable = sqliteTable(
  'likes_to_questions',
  {
    userId: text('user_id')
      .notNull()
      .references(() => usersTable.id, { onDelete: 'cascade' }),
    questionId: text('question_id')
      .notNull()
      .references(() => questionsTable.id, { onDelete: 'cascade' }),
  },
  (t) => ({
    pk: primaryKey({ columns: [t.userId, t.questionId] }),
  })
)


attempting to add a new row (see the picture) will result in error 787
image.png
Was this page helpful?