import { pgTable, text, timestamp, uuid, boolean, integer, index, } from "drizzle-orm/pg-core"; // Processing states for background jobs export type ProcessingStatus = "uploading" | "processing" | "ready" | "failed"; export const memories = pgTable( "memories", { id: uuid("id").primaryKey().defaultRandom(), familyId: uuid("family_id").notNull(), childId: uuid("child_id"), title: text("title"), description: text("description"), takenAt: timestamp("taken_at"), r2Key: text("r2_key").notNull(), r2ThumbnailKey: text("r2_thumbnail_key"), mimeType: text("mime_type"), sizeBytes: integer("size_bytes"), width: integer("width"), height: integer("height"), visionCaption: text("vision_caption"), // vision_tags is text[] in DB — handled with raw SQL // vision_embedding is vector(1536) in DB — handled with raw SQL isPrivate: boolean("is_private").default(false).notNull(), processingStatus: text("processing_status").$type().default("uploading").notNull(), uploadedBy: uuid("uploaded_by"), createdAt: timestamp("created_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), }, (table) => [ index("memories_family_idx").on(table.familyId), index("memories_child_idx").on(table.childId), ] ); export const attachments = pgTable( "attachments", { id: uuid("id").primaryKey().defaultRandom(), familyId: uuid("family_id").notNull(), logEntryId: uuid("log_entry_id"), r2Key: text("r2_key").notNull(), r2ThumbnailKey: text("r2_thumbnail_key"), mimeType: text("mime_type"), sizeBytes: integer("size_bytes"), uploadedBy: uuid("uploaded_by"), createdAt: timestamp("created_at").defaultNow().notNull(), }, (table) => [ index("attachments_family_idx").on(table.familyId), ] ); export type Memory = typeof memories.$inferSelect; export type NewMemory = typeof memories.$inferInsert; export type Attachment = typeof attachments.$inferSelect;