Resolved: Need help with my multi column primary and foreign key table

Setup:
Turso / libsql, dialect is set to turso
Versions:
    "@libsql/client": "^0.14.0"
    "drizzle-orm": "^0.34.1"
    "drizzle-kit": "^0.25.0"


Hey I have created this table:
export const userAsyncTasks = createTable(
  "userAsyncTask",
  {
    userId: text("userId").notNull(),
    identifier: text("identifier").notNull(),
    type: text("type", { enum: userAsyncTaskTypeEnum }).notNull(),
    data: text("data", { mode: "json" }),
    startedAt: int("startedAt", { mode: "timestamp" }).notNull(),
    timeoutAt: int("timeoutAt", { mode: "timestamp" }),
  },
  (table) => ({
    pk: primaryKey({ columns: [table.userId, table.type, table.identifier] }),
    fk: foreignKey({
      columns: [table.userId],
      foreignColumns: [users.id],
    })
      .onDelete("cascade")
      .onUpdate("cascade"),
  }),
);
Was this page helpful?