24 lines
1.4 KiB
TypeScript
24 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(),
|
|
}, 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),
|
|
}))
|