From 675b4e3d8ffcb57a041db285417d81e61284d900 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Sun, 14 Sep 2025 05:28:01 +0000
Subject: (대표님) RFQ-last, tbe-last, 기본계약 템플릿 내 견적,입찰,계약 추가,
 env.dev NAS_PATH 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 db/migrations/0356_powerful_prima.sql | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 db/migrations/0356_powerful_prima.sql

(limited to 'db/migrations/0356_powerful_prima.sql')

diff --git a/db/migrations/0356_powerful_prima.sql b/db/migrations/0356_powerful_prima.sql
new file mode 100644
index 00000000..b7011a81
--- /dev/null
+++ b/db/migrations/0356_powerful_prima.sql
@@ -0,0 +1,32 @@
+ALTER TABLE "rfq_last_tbe_communications" DISABLE ROW LEVEL SECURITY;--> statement-breakpoint
+ALTER TABLE "rfq_last_tbe_evaluation_items" DISABLE ROW LEVEL SECURITY;--> statement-breakpoint
+DROP VIEW "public"."tbe_session_summary_view";--> statement-breakpoint
+DROP TABLE "rfq_last_tbe_communications" CASCADE;--> statement-breakpoint
+DROP TABLE "rfq_last_tbe_evaluation_items" CASCADE;--> statement-breakpoint
+ALTER TABLE "rfq_last_tbe_vendor_documents" RENAME COLUMN "is_response_to" TO "is_response_to_review_id";--> statement-breakpoint
+ALTER TABLE "rfq_last_tbe_vendor_documents" DROP CONSTRAINT "rfq_last_tbe_vendor_documents_is_response_to_rfq_last_tbe_communications_id_fk";
+--> statement-breakpoint
+ALTER TABLE "rfq_last_tbe_vendor_documents" ADD CONSTRAINT "rfq_last_tbe_vendor_documents_is_response_to_review_id_rfq_last_tbe_document_reviews_id_fk" FOREIGN KEY ("is_response_to_review_id") REFERENCES "public"."rfq_last_tbe_document_reviews"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "rfq_last_tbe_sessions" DROP COLUMN "evaluation_score";--> statement-breakpoint
+ALTER TABLE "rfq_last_tbe_sessions" DROP COLUMN "evaluation_grade";--> statement-breakpoint
+CREATE VIEW "public"."tbe_session_summary_view" AS (select "tbe"."id" as "tbe_id", "tbe"."session_code" as "session_code", "tbe"."session_title" as "session_title", "rfq"."rfq_code" as "rfq_code", "vendor"."vendor_name" as "vendor_name", "vendor"."vendor_code" as "vendor_code", "tbe"."status" as "status", "tbe"."evaluation_result" as "evaluation_result", "lead_evaluator"."name" as "lead_evaluator_name", (
+                SELECT COUNT(*)
+                FROM rfq_last_tbe_document_reviews
+                WHERE tbe_session_id = "tbe"."id"
+            ) as "total_documents", (
+                SELECT COUNT(*)
+                FROM rfq_last_tbe_document_reviews
+                WHERE tbe_session_id = "tbe"."id"
+                AND review_status IN ('검토완료', '승인')
+            ) as "reviewed_documents", (
+                SELECT COUNT(*)
+                FROM rfq_last_tbe_pdftron_comments pc
+                JOIN rfq_last_tbe_document_reviews dr ON pc.document_review_id = dr.id
+                WHERE dr.tbe_session_id = "tbe"."id"
+            ) as "total_comments", (
+                SELECT COUNT(*)
+                FROM rfq_last_tbe_pdftron_comments pc
+                JOIN rfq_last_tbe_document_reviews dr ON pc.document_review_id = dr.id
+                WHERE dr.tbe_session_id = "tbe"."id"
+                AND pc.status = 'open'
+            ) as "unresolved_comments", "tbe"."actual_start_date" as "actual_start_date", "tbe"."actual_end_date" as "actual_end_date", "tbe"."created_at" as "created_at", "tbe"."updated_at" as "updated_at" from "rfq_last_tbe_sessions" "tbe" left join "rfqs_last" "rfq" on "tbe"."rfqs_last_id" = "rfq"."id" left join "vendors" "vendor" on "tbe"."vendor_id" = "vendor"."id" left join "users" "lead_evaluator" on "tbe"."lead_evaluator_id" = "lead_evaluator"."id");
\ No newline at end of file
-- 
cgit v1.2.3

