summaryrefslogtreecommitdiff
path: root/db/migrations/0004_common_warlock.sql
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-04-28 02:13:30 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-04-28 02:13:30 +0000
commitef4c533ebacc2cdc97e518f30e9a9350004fcdfb (patch)
tree345251a3ed0f4429716fa5edaa31024d8f4cb560 /db/migrations/0004_common_warlock.sql
parent9ceed79cf32c896f8a998399bf1b296506b2cd4a (diff)
~20250428 작업사항
Diffstat (limited to 'db/migrations/0004_common_warlock.sql')
-rw-r--r--db/migrations/0004_common_warlock.sql19
1 files changed, 19 insertions, 0 deletions
diff --git a/db/migrations/0004_common_warlock.sql b/db/migrations/0004_common_warlock.sql
new file mode 100644
index 00000000..88977d7e
--- /dev/null
+++ b/db/migrations/0004_common_warlock.sql
@@ -0,0 +1,19 @@
+DROP VIEW "public"."vendor_response_cbe_view";--> statement-breakpoint
+CREATE VIEW "public"."vendor_response_cbe_view" AS (select "vendor_responses"."id" as "response_id", "vendor_responses"."rfq_id" as "rfq_id", "vendor_responses"."vendor_id" as "vendor_id", "vendor_responses"."response_status" as "response_status", "vendor_responses"."notes" as "response_notes", "vendor_responses"."responded_by" as "responded_by", "vendor_responses"."responded_at" as "responded_at", "vendor_responses"."updated_at" as "response_updated_at", "rfqs"."rfq_code" as "rfq_code", "rfqs"."description" as "rfq_description", "rfqs"."due_date" as "rfq_due_date", "rfqs"."status" as "rfq_status", "rfqs"."rfq_type" as "rfq_type", "vendors"."vendor_name" as "vendor_name", "vendors"."vendor_code" as "vendor_code", "vendors"."status" as "vendor_status", "projects"."id" as "project_id", "projects"."code" as "project_code", "projects"."name" as "project_name", "vendor_commercial_responses"."id" as "commercial_response_id", "vendor_commercial_responses"."total_price" as "total_price", "vendor_commercial_responses"."currency" as "currency", "vendor_commercial_responses"."payment_terms" as "payment_terms", "vendor_commercial_responses"."incoterms" as "incoterms", "vendor_commercial_responses"."delivery_period" as "delivery_period", "vendor_commercial_responses"."warranty_period" as "warranty_period", "vendor_commercial_responses"."validity_period" as "validity_period", "vendor_commercial_responses"."price_breakdown" as "price_breakdown", "vendor_commercial_responses"."commercial_notes" as "commercial_notes", "vendor_commercial_responses"."created_at" as "commercial_created_at", "vendor_commercial_responses"."updated_at" as "commercial_updated_at", (
+ SELECT COUNT(*)
+ FROM "vendor_response_attachments"
+ WHERE "vendor_response_attachments"."response_id" = "vendor_responses"."id"
+ ) as "attachment_count", (
+ SELECT COUNT(*)
+ FROM "vendor_response_attachments"
+ WHERE "vendor_response_attachments"."commercial_response_id" = "vendor_commercial_responses"."id"
+ ) as "commercial_attachment_count", (
+ SELECT COUNT(*)
+ FROM "vendor_response_attachments"
+ WHERE "vendor_response_attachments"."response_id" = "vendor_responses"."id"
+ AND "vendor_response_attachments"."attachment_type" = 'TECHNICAL_SPEC'
+ ) as "technical_attachment_count", (
+ SELECT MAX("uploaded_at")
+ FROM "vendor_response_attachments"
+ WHERE "vendor_response_attachments"."response_id" = "vendor_responses"."id"
+ ) as "latest_attachment_date" from "vendor_responses" inner join "rfqs" on "vendor_responses"."rfq_id" = "rfqs"."id" inner join "vendors" on "vendor_responses"."vendor_id" = "vendors"."id" left join "projects" on "rfqs"."project_id" = "projects"."id" left join "vendor_commercial_responses" on "vendor_commercial_responses"."response_id" = "vendor_responses"."id"); \ No newline at end of file