-- View: public.document_details

-- DROP VIEW public.document_details;

CREATE OR REPLACE VIEW public.document_details
 AS
 SELECT d.doc_id,
    d.title,
    dt.type_name,
    ldv.content,
    ldv.updated_at
   FROM documents d
     JOIN document_types dt ON d.type_id = dt.type_id
     LEFT JOIN latest_document_versions ldv ON d.doc_id = ldv.doc_id;

ALTER TABLE public.document_details
    OWNER TO dbuser01;

