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"),
}),
);
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"),
}),
);