From 0ffba85c79a7693d887e6fe0cd991e42faea8f36 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 15 Sep 2025 10:15:25 +0000
Subject: (공통) 스키마 index.ts 및 마이그레이션 파일 커밋
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 db/migrations/0368_shocking_leopardon.sql | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 db/migrations/0368_shocking_leopardon.sql

(limited to 'db/migrations/0368_shocking_leopardon.sql')

diff --git a/db/migrations/0368_shocking_leopardon.sql b/db/migrations/0368_shocking_leopardon.sql
new file mode 100644
index 00000000..957587c6
--- /dev/null
+++ b/db/migrations/0368_shocking_leopardon.sql
@@ -0,0 +1,14 @@
+DROP VIEW "public"."tbe_documents_view";--> statement-breakpoint
+CREATE VIEW "public"."tbe_documents_view" AS (select dr.id as "document_review_id", COALESCE(dr.tbe_session_id, vd.tbe_session_id) as "tbe_session_id", 
+        CASE 
+          WHEN dr.id IS NOT NULL THEN dr.document_source
+          WHEN vd.id IS NOT NULL THEN 'vendor'
+          ELSE NULL
+        END
+       as "document_source", COALESCE(dr.buyer_attachment_id, vd.id) as "document_id", COALESCE(dr.document_type, vd.document_type) as "document_type", COALESCE(dr.document_name, vd.original_file_name) as "document_name", COALESCE(ba_rev.original_file_name, vd.original_file_name) as "original_file_name", COALESCE(ba_rev.file_path, vd.file_path) as "file_path", COALESCE(ba_rev.file_size, vd.file_size) as "file_size", COALESCE(ba_rev.file_type, vd.file_type) as "file_type", COALESCE(dr.review_status, vd.review_status, '미검토') as "review_status", dr.technical_compliance as "technical_compliance", dr.quality_acceptable as "quality_acceptable", COALESCE(dr.requires_revision, false) as "requires_revision", COALESCE(dr.has_pdftron_comments, false) as "has_pdftron_comments", dr.pdftron_document_id as "pdftron_document_id", COALESCE(dr.pdftron_annotation_count, 0) as "pdftron_annotation_count", COALESCE(dr.reviewed_by, vd.reviewed_by) as "reviewed_by", COALESCE(dr.reviewed_at, vd.reviewed_at) as "reviewed_at", COALESCE(dr.review_comments, vd.review_comments) as "review_comments", vd.submitted_by as "submitted_by", vd.submitted_at as "submitted_at", COALESCE(dr.created_at, vd.submitted_at) as "created_at", COALESCE(dr.updated_at, vd.submitted_at) as "updated_at" from (
+        SELECT * FROM rfq_last_tbe_document_reviews
+      ) dr
+      FULL OUTER JOIN (
+        SELECT * FROM rfq_last_tbe_vendor_documents
+      ) vd ON false
+     left join "rfq_last_attachments" "ba" on dr.buyer_attachment_id = "ba"."id" left join "rfq_last_attachment_revisions" "ba_rev" on dr.buyer_attachment_revision_id = "ba_rev"."id");
\ No newline at end of file
-- 
cgit v1.2.3

