--
-- PostgreSQL database dump
--

--
-- Name: document_receivers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.document_receivers (
    document_id uuid NOT NULL,
    person_id uuid NOT NULL
);


--
-- Name: document_tags; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.document_tags (
    document_id uuid NOT NULL,
    tag_id uuid NOT NULL
);


--
-- Name: documents; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.documents (
    meta_date date,
    created_at timestamp(6) without time zone,
    updated_at timestamp(6) without time zone,
    id uuid NOT NULL,
    sender_id uuid,
    file_path character varying(255),
    meta_document_location character varying(255),
    meta_location character varying(255),
    original_filename character varying(255) NOT NULL,
    status character varying(255) NOT NULL,
    summary text,
    title character varying(255) NOT NULL,
    transcription text,
    CONSTRAINT documents_status_check CHECK (((status)::text = ANY ((ARRAY['PLACEHOLDER'::character varying, 'UPLOADED'::character varying, 'TRANSCRIBED'::character varying, 'REVIEWED'::character varying, 'ARCHIVED'::character varying])::text[])))
);


--
-- Name: group_permissions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.group_permissions (
    group_id uuid NOT NULL,
    permission character varying(255)
);


--
-- Name: persons; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.persons (
    id uuid NOT NULL,
    alias character varying(255),
    first_name character varying(255) NOT NULL,
    last_name character varying(255) NOT NULL
);


--
-- Name: tag; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.tag (
    id uuid NOT NULL,
    name character varying(255) NOT NULL
);


--
-- Name: user_groups; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.user_groups (
    id uuid NOT NULL,
    name character varying(255) NOT NULL
);


--
-- Name: users; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.users (
    enabled boolean NOT NULL,
    created_at timestamp(6) without time zone,
    id uuid NOT NULL,
    email character varying(255),
    password character varying(255) NOT NULL,
    username character varying(255) NOT NULL
);


--
-- Name: users_groups; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.users_groups (
    group_id uuid NOT NULL,
    user_id uuid NOT NULL
);


--
-- Name: document_receivers document_receivers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.document_receivers
    ADD CONSTRAINT document_receivers_pkey PRIMARY KEY (document_id, person_id);


--
-- Name: document_tags document_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.document_tags
    ADD CONSTRAINT document_tags_pkey PRIMARY KEY (document_id, tag_id);


--
-- Name: documents documents_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.documents
    ADD CONSTRAINT documents_pkey PRIMARY KEY (id);


--
-- Name: persons persons_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.persons
    ADD CONSTRAINT persons_pkey PRIMARY KEY (id);


--
-- Name: tag tag_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.tag
    ADD CONSTRAINT tag_name_key UNIQUE (name);


--
-- Name: tag tag_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.tag
    ADD CONSTRAINT tag_pkey PRIMARY KEY (id);


--
-- Name: user_groups user_groups_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_groups
    ADD CONSTRAINT user_groups_name_key UNIQUE (name);


--
-- Name: user_groups user_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_groups
    ADD CONSTRAINT user_groups_pkey PRIMARY KEY (id);


--
-- Name: users_groups users_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users_groups
    ADD CONSTRAINT users_groups_pkey PRIMARY KEY (group_id, user_id);


--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_pkey PRIMARY KEY (id);


--
-- Name: users users_username_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_username_key UNIQUE (username);


--
-- Name: users_groups fk1qwqr38oun4xcttk576wevhxn; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users_groups
    ADD CONSTRAINT fk1qwqr38oun4xcttk576wevhxn FOREIGN KEY (group_id) REFERENCES public.user_groups(id);


--
-- Name: group_permissions fkaqmvqpbaqnfeg5ixk88k8u6i9; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_permissions
    ADD CONSTRAINT fkaqmvqpbaqnfeg5ixk88k8u6i9 FOREIGN KEY (group_id) REFERENCES public.user_groups(id);


--
-- Name: document_tags fkc99c5qjulwx9gru07yrhicgd2; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.document_tags
    ADD CONSTRAINT fkc99c5qjulwx9gru07yrhicgd2 FOREIGN KEY (document_id) REFERENCES public.documents(id);


--
-- Name: document_receivers fkcg7r68qvosqricx1betgrlt7s; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.document_receivers
    ADD CONSTRAINT fkcg7r68qvosqricx1betgrlt7s FOREIGN KEY (person_id) REFERENCES public.persons(id);


--
-- Name: users_groups fkg6fu0mfuj9eqfd9aro1nc40nn; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users_groups
    ADD CONSTRAINT fkg6fu0mfuj9eqfd9aro1nc40nn FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: documents fkl5xhww7es3b4um01vmly4y18m; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.documents
    ADD CONSTRAINT fkl5xhww7es3b4um01vmly4y18m FOREIGN KEY (sender_id) REFERENCES public.persons(id);


--
-- Name: document_tags fkl8pxq2mt0yxvg6ukrcx1aijsq; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.document_tags
    ADD CONSTRAINT fkl8pxq2mt0yxvg6ukrcx1aijsq FOREIGN KEY (tag_id) REFERENCES public.tag(id);


--
-- Name: document_receivers fks7t60twjgfmpeqcuc3g0fvjpm; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.document_receivers
    ADD CONSTRAINT fks7t60twjgfmpeqcuc3g0fvjpm FOREIGN KEY (document_id) REFERENCES public.documents(id);



