Files
FEDEO/backend/db/schema/tenant_export_jobs.ts

42 lines
1.3 KiB
TypeScript

import {
pgTable,
uuid,
bigint,
timestamp,
text,
integer,
} from "drizzle-orm/pg-core"
import { tenants } from "./tenants"
import { authUsers } from "./auth_users"
export const tenantExportJobs = pgTable("tenant_export_jobs", {
id: uuid("id").primaryKey().defaultRandom(),
createdAt: timestamp("created_at", { withTimezone: true })
.notNull()
.defaultNow(),
updatedAt: timestamp("updated_at", { withTimezone: true }),
completedAt: timestamp("completed_at", { withTimezone: true }),
tenantId: bigint("tenant_id", { mode: "number" })
.notNull()
.references(() => tenants.id, { onDelete: "cascade" }),
createdBy: uuid("created_by").references(() => authUsers.id),
status: text("status").notNull().default("queued"),
filename: text("filename").notNull(),
storagePath: text("storage_path"),
contentType: text("content_type").notNull().default("application/zip"),
fileSize: bigint("file_size", { mode: "number" }),
error: text("error"),
filesTotal: integer("files_total").notNull().default(0),
filesDone: integer("files_done").notNull().default(0),
})
export type TenantExportJob = typeof tenantExportJobs.$inferSelect
export type NewTenantExportJob = typeof tenantExportJobs.$inferInsert