diff options
Diffstat (limited to 'db/schema/ocr.ts')
| -rw-r--r-- | db/schema/ocr.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/db/schema/ocr.ts b/db/schema/ocr.ts index 289eb297..12382aa4 100644 --- a/db/schema/ocr.ts +++ b/db/schema/ocr.ts @@ -9,9 +9,10 @@ import { boolean, jsonb, text, - serial + serial , uniqueIndex } from 'drizzle-orm/pg-core'; import { relations } from 'drizzle-orm'; +import { users } from './users'; // OCR 세션 테이블 (전체 처리 정보) export const ocrSessions = pgTable('ocr_sessions', { @@ -57,8 +58,13 @@ export const ocrRows = pgTable('ocr_rows', { confidence: decimal('confidence', { precision: 5, scale: 4 }), // 0.0000 ~ 1.0000 sourceTable: integer('source_table'), sourceRow: integer('source_row'), + userId: integer("user_id") + .references(() => users.id, { onDelete: "set null" }), createdAt: timestamp('created_at').notNull().defaultNow(), -}); +}, (t) => ({ + // tableId + reportNo + no 조합이 유일 + uniqReportAndNo: uniqueIndex('idx_ocr_report_no_unique').on(t.reportNo, t.no, t.tagNo, t.jointNo, t.jointType), +})); // 회전 시도 결과 export const ocrRotationAttempts = pgTable('ocr_rotation_attempts', { |
