From 9ceed79cf32c896f8a998399bf1b296506b2cd4a Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Tue, 8 Apr 2025 03:08:19 +0000
Subject: 로그인 및 미들웨어 처리. 구조 변경
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 db/migrations_backup/0097_luxuriant_taskmaster.sql | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 db/migrations_backup/0097_luxuriant_taskmaster.sql

(limited to 'db/migrations_backup/0097_luxuriant_taskmaster.sql')

diff --git a/db/migrations_backup/0097_luxuriant_taskmaster.sql b/db/migrations_backup/0097_luxuriant_taskmaster.sql
new file mode 100644
index 00000000..db42ff3f
--- /dev/null
+++ b/db/migrations_backup/0097_luxuriant_taskmaster.sql
@@ -0,0 +1,31 @@
+DROP VIEW "public"."vendor_investigations_view";--> statement-breakpoint
+CREATE VIEW "public"."vendor_investigations_view" AS (select "vendor_investigations"."id", "vendor_investigations"."status", "vendor_investigations"."scheduled_start_at", "vendor_investigations"."scheduled_end_at", "vendor_investigations"."completed_at", "vendor_investigations"."investigation_notes", "vendor_investigations"."created_at", "vendor_investigations"."updated_at", "vendors"."id", "vendors"."vendor_name", "vendors"."vendor_code", "vendors"."tax_id", "vendors"."status", "vendors"."country", "vendors"."email", "vendors"."phone", "vendors"."website", "vendors"."created_at", "vendors"."updated_at", (
+        SELECT COALESCE(
+          json_agg(json_build_object(
+            'contactId', c.id,
+            'contactName', c.contact_name,
+            'contactEmail', c.contact_email,
+            'contactPhone', c.contact_phone,
+            'contactPosition', c.contact_position,
+            'isPrimary', c.is_primary,
+            'createdAt', c.created_at,
+            'updatedAt', c.updated_at
+          )),
+          '[]'::json
+        )
+        FROM vendor_contacts c
+        WHERE c.vendor_id = "vendors"."id"
+      ) as "contacts", (
+        SELECT COALESCE(
+          json_agg(json_build_object(
+            'itemId', pi.id,
+            'vendorId', pi.vendor_id,
+            'itemCode', pi.item_code,
+            'createdAt', pi.created_at,
+            'updatedAt', pi.updated_at
+          )),
+          '[]'::json
+        )
+        FROM vendor_possible_items pi
+        WHERE pi.vendor_id = "vendors"."id"
+      ) as "possibleItems" from "vendor_investigations" left join "vendors" on "vendor_investigations"."vendor_id" = "vendors"."id");
\ No newline at end of file
-- 
cgit v1.2.3

