diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-08-21 06:57:36 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-08-21 06:57:36 +0000 |
| commit | 02b1cf005cf3e1df64183d20ba42930eb2767a9f (patch) | |
| tree | e932c54d5260b0e6fda2b46be2a6ba1c3ee30434 /db/migrations/0300_tearful_silverclaw.sql | |
| parent | d78378ecd7ceede1429359f8058c7a99ac34b1b7 (diff) | |
(대표님, 최겸) 설계메뉴추가, 작업사항 업데이트
설계메뉴 - 문서관리
설계메뉴 - 벤더 데이터
gtc 메뉴 업데이트
정보시스템 - 메뉴리스트 및 정보 업데이트
파일 라우트 업데이트
엑셀임포트 개선
기본계약 개선
벤더 가입과정 변경 및 개선
벤더 기본정보 - pq
돌체 오류 수정 및 개선
벤더 로그인 과정 이메일 오류 수정
Diffstat (limited to 'db/migrations/0300_tearful_silverclaw.sql')
| -rw-r--r-- | db/migrations/0300_tearful_silverclaw.sql | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/db/migrations/0300_tearful_silverclaw.sql b/db/migrations/0300_tearful_silverclaw.sql new file mode 100644 index 00000000..96b862ea --- /dev/null +++ b/db/migrations/0300_tearful_silverclaw.sql @@ -0,0 +1,91 @@ +DROP VIEW "public"."vendor_detail_view";--> statement-breakpoint +--vendors_with_types drop 시에, initial_rfq_detail 가 먼저 drop 되어야 함. 따라서 수동 추가하였습니다.(최겸) +DROP VIEW "public"."initial_rfq_detail";--> statement-breakpoint +DROP VIEW "public"."vendors_with_types";--> statement-breakpoint +ALTER TABLE "vendors" ADD COLUMN "address_detail" text;--> statement-breakpoint +ALTER TABLE "vendors" ADD COLUMN "postal_code" varchar(20);--> statement-breakpoint +CREATE VIEW "public"."vendor_detail_view" AS (select "id", "vendor_name", "vendor_code", "tax_id", "address", "address_detail", "postal_code", "business_size", "country", "phone", "email", "website", "status", "representative_name", "representative_birth", "representative_email", "representative_phone", "corporate_registration_number", "credit_agency", "credit_rating", "cash_flow_rating", "created_at", "updated_at", + (SELECT COALESCE( + json_agg( + json_build_object( + 'id', c.id, + 'contactName', c.contact_name, + 'contactPosition', c.contact_position, + 'contactEmail', c.contact_email, + 'contactPhone', c.contact_phone, + 'isPrimary', c.is_primary + ) + ), + '[]'::json + ) + FROM vendor_contacts c + WHERE c.vendor_id = vendors.id) + as "contacts", + (SELECT COALESCE( + json_agg( + json_build_object( + 'id', a.id, + 'fileName', a.file_name, + 'filePath', a.file_path, + 'attachmentType', a.attachment_type, + 'createdAt', a.created_at + ) + ORDER BY a.attachment_type, a.created_at DESC + ), + '[]'::json + ) + FROM vendor_attachments a + WHERE a.vendor_id = vendors.id) + as "attachments", + (SELECT COUNT(*) + FROM vendor_attachments a + WHERE a.vendor_id = vendors.id) + as "attachment_count", + (SELECT COUNT(*) + FROM vendor_contacts c + WHERE c.vendor_id = vendors.id) + as "contact_count" from "vendors");--> statement-breakpoint +CREATE VIEW "public"."vendors_with_types" AS (select "vendors"."id" as "id", "vendors"."vendor_name" as "vendor_name", "vendors"."vendor_code" as "vendor_code", "vendors"."tax_id" as "tax_id", "vendors"."address" as "address", "vendors"."address_detail" as "address_detail", "vendors"."postal_code" as "postal_code", "vendors"."country" as "country", "vendors"."phone" as "phone", "vendors"."email" as "email", "vendors"."business_size" as "business_size", "vendors"."website" as "website", "vendors"."status" as "status", "vendors"."vendor_type_id" as "vendor_type_id", "vendors"."representative_name" as "representative_name", "vendors"."representative_birth" as "representative_birth", "vendors"."representative_email" as "representative_email", "vendors"."representative_phone" as "representative_phone", "vendors"."corporate_registration_number" as "corporate_registration_number", "vendors"."items" as "items", "vendors"."credit_agency" as "credit_agency", "vendors"."credit_rating" as "credit_rating", "vendors"."cash_flow_rating" as "cash_flow_rating", "vendors"."created_at" as "created_at", "vendors"."updated_at" as "updated_at", "vendor_types"."name_ko" as "vendor_type_name", "vendor_types"."name_en" as "vendor_type_name_en", "vendor_types"."code" as "vendor_type_code", + CASE + WHEN "vendors"."status" = 'ACTIVE' THEN '정규업체' + WHEN "vendors"."status" IN ('INACTIVE', 'BLACKLISTED', 'REJECTED') THEN '' + ELSE '잠재업체' + END + as "vendor_category" from "vendors" left join "vendor_types" on "vendors"."vendor_type_id" = "vendor_types"."id"); + +CREATE VIEW "public"."initial_rfq_detail" AS--> statement-breakpoint +SELECT + br.id AS rfq_id, + br.rfq_code, + br.status AS rfq_status, + ir.id AS initial_rfq_id, + ir.initial_rfq_status, + ir.vendor_id, + v.vendor_code, + v.vendor_name, + v.vendor_category, + v.country AS vendor_country, + v.business_size AS vendor_business_size, + ir.due_date, + ir.valid_date, + ir.incoterms_code, + inc.description AS incoterms_description, + ir.short_list, + ir.return_yn, + ir.cp_request_yn, + ir.prject_gtc_yn, + ir.return_revision, + ir.rfq_revision, + ir.gtc, + ir.gtc_valid_date, + ir.classification, + ir.sparepart, + ir.created_at, + ir.updated_at +FROM b_rfqs br +JOIN initial_rfq ir + ON br.id = ir.rfq_id +LEFT JOIN vendors_with_types v + ON ir.vendor_id = v.id +LEFT JOIN incoterms inc + ON ir.incoterms_code = inc.code;
\ No newline at end of file |
