initttt
This commit is contained in:
35
packages/db/schema/task.schema.ts
Normal file
35
packages/db/schema/task.schema.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
integer,
|
||||
json,
|
||||
pgTable,
|
||||
text,
|
||||
timestamp,
|
||||
varchar,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { user } from "./better.auth.schema";
|
||||
import { relations } from "drizzle-orm";
|
||||
|
||||
export const task = pgTable("task", {
|
||||
id: text("id").primaryKey(),
|
||||
type: varchar("type", { length: 32 }).notNull(),
|
||||
status: varchar("status", { length: 16 }).notNull(),
|
||||
progress: integer("progress").default(0).notNull(),
|
||||
payload: json("payload").$type<Record<string, any>>(),
|
||||
result: json("result").$type<Record<string, any>>(),
|
||||
error: json("error").$type<Record<string, any>>(),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
resourceId: text("resource_id").notNull(),
|
||||
startedAt: timestamp("started_at"),
|
||||
completedAt: timestamp("completed_at"),
|
||||
createdAt: timestamp("created_at").notNull(),
|
||||
updatedAt: timestamp("updated_at").notNull(),
|
||||
});
|
||||
|
||||
export const taskRelations = relations(task, ({ one }) => ({
|
||||
userAccount: one(user, {
|
||||
fields: [task.userId],
|
||||
references: [user.id],
|
||||
}),
|
||||
}));
|
||||
Reference in New Issue
Block a user