Files
FEDEO/backend/db/schema/scanner_inbox.ts
flfeders 052a3a8446
All checks were successful
Build and Release FEDEO / verify (push) Successful in 1m0s
Build and Release FEDEO / build-and-release (push) Successful in 5m56s
feat(documents): file scanner inbox documents with folder and type
2026-09-29 16:48:15 +02:00

25 lines
1.4 KiB
TypeScript

import { bigint, boolean, index, pgTable, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core"
import { tenants } from "./tenants"
import { files } from "./files"
export const scannerInboxConnections = pgTable("scanner_inbox_connections", {
tenantId: bigint("tenant_id", { mode: "number" }).primaryKey().references(() => tenants.id, { onDelete: "cascade" }),
username: text("username").notNull().unique(),
passwordHash: text("password_hash").notNull(),
active: boolean("active").notNull().default(true),
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp("updated_at", { withTimezone: true }),
})
export const scannerInboxDocuments = pgTable("scanner_inbox_documents", {
fileId: uuid("file_id").primaryKey().references(() => files.id, { onDelete: "cascade" }),
tenantId: bigint("tenant_id", { mode: "number" }).notNull().references(() => tenants.id, { onDelete: "cascade" }),
remoteFilename: text("remote_filename").notNull(),
checksum: text("checksum").notNull(),
receivedAt: timestamp("received_at", { withTimezone: true }).notNull().defaultNow(),
filedAt: timestamp("filed_at", { withTimezone: true }),
}, table => ({
filenameKey: uniqueIndex("scanner_inbox_documents_filename_key").on(table.tenantId, table.remoteFilename),
receivedIdx: index("scanner_inbox_documents_received_idx").on(table.tenantId, table.receivedAt),
}))