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/0056_majestic_khan.sql | 34 +++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 db/migrations_backup/0056_majestic_khan.sql

(limited to 'db/migrations_backup/0056_majestic_khan.sql')

diff --git a/db/migrations_backup/0056_majestic_khan.sql b/db/migrations_backup/0056_majestic_khan.sql
new file mode 100644
index 00000000..161e1c3c
--- /dev/null
+++ b/db/migrations_backup/0056_majestic_khan.sql
@@ -0,0 +1,34 @@
+CREATE VIEW "public"."document_stages_view" AS (
+  SELECT
+    d.id AS document_id,
+    d.doc_number,
+    d.title,
+    d.status,
+    d.issued_date,
+    d.contract_id,
+
+    (
+      SELECT COUNT(*) 
+      FROM issue_stages 
+      WHERE document_id = d.id
+    ) AS stage_count,
+
+    (
+      SELECT json_agg(
+        json_build_object(
+          'id', i.id,
+          'stageName', i.stage_name,
+          'planDate', i.plan_date,
+          'actualDate', i.actual_date,
+          'createdAt', i.created_at,
+          'updatedAt', i.updated_at
+        )
+      )
+      FROM issue_stages i
+      WHERE i.document_id = d.id
+    ) AS stage_list,
+
+    d.created_at,
+    d.updated_at
+  FROM documents d
+);
\ No newline at end of file
-- 
cgit v1.2.3

