On delete cascade not working

I have the following tables:
export const exercises = sqliteTable("exercises", {
  id: integer("id").primaryKey().notNull(),
  created_at: integer("created_at").default(sql`(strftime('%Y-%m-%d', 'now'))`),
  exercise_name: text("exercise_name").notNull(),
});

export const labels = sqliteTable("labels", {
  id: integer("id").primaryKey().notNull(),
  name: text("name").notNull(),
  parent_id: integer("parent_id"),
});

export const exercise_label = sqliteTable("exercise_label", {
  exercise_id: integer("exercise_id")
    .references(() => exercises.id)
    .notNull(),
  label_id: integer("label_id")
    .references(() => labels.id)
    .notNull(),
});

export const sets = sqliteTable("sets", {
  id: integer("id").primaryKey().notNull(),
  exercise_id: integer("exercise_id")
    .references(() => exercises.id, { onDelete: "cascade" })
    .notNull(),
  date: integer("date")
    .default(sql`(strftime('%Y-%m-%d', 'now'))`)
    .notNull(),
  kg: integer("kg").notNull(),
  reps: integer("reps").notNull(),
});


Note that int the sets table, there is a statement that on deletion of an exercise, the sets should also be deleted.

however, when i test this, the rows in sets with the exercise id of the deleted exercise are not deleted.

Am I doing something wrong?
Was this page helpful?