DROP VIEW "public"."vendors_with_types";--> 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");