-- Schema only (no data). Exported from V1 database in read-only mode.
-- Source: prod, pg_dump --schema-only. Do not commit credentials.
--
--
-- PostgreSQL database dump
--


-- Dumped from database version 14.21 (Debian 14.21-1.pgdg11+1)
-- Dumped by pg_dump version 18.1 (Debian 18.1-1.pgdg11+2)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--

-- *not* creating schema, since initdb creates it


--
-- Name: shadow; Type: SCHEMA; Schema: -; Owner: -
--

CREATE SCHEMA shadow;


--
-- Name: EAnchoringStatus; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."EAnchoringStatus" AS ENUM (
    'QUEUED',
    'ATTEMPTING',
    'VERIFIED_ON_CHAIN',
    'VERIFYING_ON_CHAIN',
    'ABANDONED'
);


--
-- Name: EAppointmentStatus; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."EAppointmentStatus" AS ENUM (
    'OPEN',
    'CLOSED'
);


--
-- Name: EBlockchainName; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."EBlockchainName" AS ENUM (
    'TEZOS'
);


--
-- Name: ECivility; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."ECivility" AS ENUM (
    'MALE',
    'FEMALE',
    'OTHERS'
);


--
-- Name: ECustomerStatus; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."ECustomerStatus" AS ENUM (
    'VALIDATED',
    'PENDING',
    'ERRONED'
);


--
-- Name: EDocumentNotaryStatus; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."EDocumentNotaryStatus" AS ENUM (
    'SENT',
    'DOWNLOADED'
);


--
-- Name: EDocumentStatus; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."EDocumentStatus" AS ENUM (
    'ASKED',
    'DEPOSITED',
    'VALIDATED',
    'REFUSED'
);


--
-- Name: EFolderStatus; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."EFolderStatus" AS ENUM (
    'LIVE',
    'ARCHIVED'
);


--
-- Name: ENotificationStatus; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."ENotificationStatus" AS ENUM (
    'READ',
    'UNREAD'
);


--
-- Name: EOfficeStatus; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."EOfficeStatus" AS ENUM (
    'ACTIVATED',
    'DESACTIVATED'
);


--
-- Name: ESubscriptionStatus; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."ESubscriptionStatus" AS ENUM (
    'ACTIVE',
    'INACTIVE'
);


--
-- Name: ESubscriptionType; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."ESubscriptionType" AS ENUM (
    'STANDARD',
    'UNLIMITED'
);


--
-- Name: EVote; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."EVote" AS ENUM (
    'NOMINATE',
    'DISMISS'
);


--
-- Name: TotpCodesReasons; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public."TotpCodesReasons" AS ENUM (
    'LOGIN',
    'RESET_PASSWORD',
    'FIRST_LOGIN'
);


SET default_tablespace = '';

SET default_table_access_method = heap;

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

CREATE TABLE public."_DeedHasDocumentTypes" (
    "A" text NOT NULL,
    "B" text NOT NULL
);


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

CREATE TABLE public."_DeedTypeHasDocumentTypes" (
    "A" text NOT NULL,
    "B" text NOT NULL
);


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

CREATE TABLE public."_OfficeFolderHasCustomers" (
    "A" text NOT NULL,
    "B" text NOT NULL
);


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

CREATE TABLE public."_OfficeFolderHasStakeholders" (
    "A" text NOT NULL,
    "B" text NOT NULL
);


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

CREATE TABLE public."_OfficeRolesHasRules" (
    "A" text NOT NULL,
    "B" text NOT NULL
);


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

CREATE TABLE public."_RolesHasRules" (
    "A" text NOT NULL,
    "B" text NOT NULL
);


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

CREATE TABLE public."_RulesGroupsHasRules" (
    "A" text NOT NULL,
    "B" text NOT NULL
);


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

CREATE TABLE public._prisma_migrations (
    id character varying(36) NOT NULL,
    checksum character varying(64) NOT NULL,
    finished_at timestamp with time zone,
    migration_name character varying(255) NOT NULL,
    logs text,
    rolled_back_at timestamp with time zone,
    started_at timestamp with time zone DEFAULT now() NOT NULL,
    applied_steps_count integer DEFAULT 0 NOT NULL
);


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

CREATE TABLE public.addresses (
    uid text NOT NULL,
    address character varying(1000) NOT NULL,
    city character varying(255) NOT NULL,
    zip_code integer NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.appointments (
    uid text NOT NULL,
    user_uid character varying(255) NOT NULL,
    choice public."EVote" DEFAULT 'NOMINATE'::public."EVote" NOT NULL,
    status public."EAppointmentStatus" DEFAULT 'OPEN'::public."EAppointmentStatus" NOT NULL
);


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

CREATE TABLE public.contacts (
    uid text NOT NULL,
    first_name character varying(255) NOT NULL,
    last_name character varying(255) NOT NULL,
    email character varying(255) NOT NULL,
    phone_number character varying(50),
    cell_phone_number character varying(50),
    civility public."ECivility" DEFAULT 'MALE'::public."ECivility" NOT NULL,
    address_uid character varying(255),
    birthdate timestamp(3) without time zone,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.customers (
    uid text NOT NULL,
    status public."ECustomerStatus" DEFAULT 'PENDING'::public."ECustomerStatus" NOT NULL,
    contact_uid character varying(255) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone,
    password character varying(255),
    office_uid character varying(255) NOT NULL
);


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

CREATE TABLE public.deed (
    uid text NOT NULL,
    deed_type_uid character varying(255) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.deed_types (
    uid text NOT NULL,
    name character varying(255) NOT NULL,
    description character varying(1000) NOT NULL,
    archived_at timestamp(3) without time zone,
    office_uid character varying(255) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.document_history (
    uid text NOT NULL,
    document_status public."EDocumentStatus" DEFAULT 'ASKED'::public."EDocumentStatus" NOT NULL,
    refused_reason character varying(1000),
    document_uid character varying(255) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.document_types (
    uid text NOT NULL,
    name character varying(255) NOT NULL,
    public_description character varying(1000) NOT NULL,
    private_description character varying(1000),
    office_uid character varying(255) NOT NULL,
    archived_at timestamp(3) without time zone,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.documents (
    uid text NOT NULL,
    document_status public."EDocumentStatus" DEFAULT 'ASKED'::public."EDocumentStatus" NOT NULL,
    document_type_uid character varying(255) NOT NULL,
    folder_uid character varying(255) NOT NULL,
    depositor_uid character varying(255) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.documents_notary (
    uid text NOT NULL,
    folder_uid character varying(255) NOT NULL,
    depositor_uid character varying(255) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone,
    customer_uid character varying(255) NOT NULL,
    document character varying(255) DEFAULT ''::character varying NOT NULL,
    document_status public."EDocumentNotaryStatus" DEFAULT 'SENT'::public."EDocumentNotaryStatus" NOT NULL
);


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

CREATE TABLE public.documents_reminder (
    uid text NOT NULL,
    document_uid character varying(255) NOT NULL,
    reminder_date timestamp(3) without time zone NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.email (
    uid text NOT NULL,
    "templateName" character varying(255) NOT NULL,
    "from" character varying(255),
    "to" character varying(255) NOT NULL,
    subject character varying(255) NOT NULL,
    "templateVariables" json DEFAULT '{}'::json NOT NULL,
    cc character varying(255)[],
    cci character varying(255)[],
    "sentAt" timestamp(3) without time zone,
    "nbTrySend" integer DEFAULT 0,
    "lastTrySendDate" timestamp(3) without time zone
);


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

CREATE TABLE public.files (
    uid text NOT NULL,
    document_uid character varying(255) NOT NULL,
    file_path character varying(255) NOT NULL,
    file_name character varying(255) NOT NULL,
    mimetype character varying(255) NOT NULL,
    hash character varying(255) NOT NULL,
    size integer NOT NULL,
    archived_at timestamp(3) without time zone,
    key character varying(255),
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.files_notary (
    uid text NOT NULL,
    document_uid character varying(255) NOT NULL,
    file_path character varying(255) NOT NULL,
    file_name character varying(255) NOT NULL,
    mimetype character varying(255) NOT NULL,
    hash character varying(255) NOT NULL,
    size integer NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone,
    key character varying(255)
);


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

CREATE TABLE public.notes (
    uid text NOT NULL,
    content character varying(1000) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone,
    customer_uid character varying(255) NOT NULL,
    folder_uid character varying(255) NOT NULL
);


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

CREATE TABLE public.notifications (
    uid text NOT NULL,
    message character varying(1000) NOT NULL,
    redirection_url character varying(255) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.office_folder_anchors (
    uid text NOT NULL,
    hash_sources text[],
    root_hash character varying(255) NOT NULL,
    blockchain public."EBlockchainName" DEFAULT 'TEZOS'::public."EBlockchainName" NOT NULL,
    status public."EAnchoringStatus" DEFAULT 'QUEUED'::public."EAnchoringStatus" NOT NULL,
    anchor_nb_try integer DEFAULT 0 NOT NULL,
    anchored_at timestamp(3) without time zone,
    tx_id character varying(255),
    tx_link character varying(255),
    tx_hash character varying(255),
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.office_folders (
    uid text NOT NULL,
    folder_number character varying(255) NOT NULL,
    name character varying(255) NOT NULL,
    description character varying(1000),
    archived_description character varying(255),
    status public."EFolderStatus" DEFAULT 'LIVE'::public."EFolderStatus" NOT NULL,
    deed_uid character varying(255) NOT NULL,
    office_uid character varying(255) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone,
    folder_anchor_uid character varying(255)
);


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

CREATE TABLE public.office_roles (
    uid text NOT NULL,
    name character varying(255) NOT NULL,
    office_uid character varying(255) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.offices (
    uid text NOT NULL,
    "idNot" character varying(255) NOT NULL,
    name character varying(255) NOT NULL,
    crpcen character varying(255) NOT NULL,
    address_uid character varying(255) NOT NULL,
    office_status public."EOfficeStatus" DEFAULT 'DESACTIVATED'::public."EOfficeStatus" NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone,
    checked_at timestamp(3) without time zone,
    rib_url character varying(255),
    rib_name character varying(255)
);


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

CREATE TABLE public.roles (
    uid text NOT NULL,
    name character varying(255) NOT NULL,
    label character varying(255) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.rules (
    uid text NOT NULL,
    name character varying(255) NOT NULL,
    label character varying(255) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone,
    namespace character varying(255) DEFAULT 'notary'::character varying NOT NULL
);


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

CREATE TABLE public.rules_groups (
    uid text NOT NULL,
    name character varying(255) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.seats (
    uid text NOT NULL,
    subscription_uid character varying(255) NOT NULL,
    user_uid character varying(255) NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.subscriptions (
    uid text NOT NULL,
    start_date timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    end_date timestamp(3) without time zone NOT NULL,
    nb_seats integer NOT NULL,
    office_uid character varying(255) NOT NULL,
    type public."ESubscriptionType" NOT NULL,
    stripe_subscription_id character varying(255) NOT NULL,
    status public."ESubscriptionStatus" DEFAULT 'ACTIVE'::public."ESubscriptionStatus" NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.totp_codes (
    uid text NOT NULL,
    customer_uid character varying(255) NOT NULL,
    code character varying(255) NOT NULL,
    reason public."TotpCodesReasons" DEFAULT 'LOGIN'::public."TotpCodesReasons" NOT NULL,
    expire_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone,
    resent boolean DEFAULT false NOT NULL
);


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

CREATE TABLE public.user_notifications (
    uid text NOT NULL,
    user_uid character varying(255) NOT NULL,
    read boolean DEFAULT false NOT NULL,
    notification_uid character varying(255) NOT NULL
);


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

CREATE TABLE public.user_whitelist (
    uid text NOT NULL,
    "idNot" character varying(255) NOT NULL,
    active boolean DEFAULT true NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


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

CREATE TABLE public.users (
    uid text NOT NULL,
    "idNot" character varying(255) NOT NULL,
    contact_uid character varying(255) NOT NULL,
    roles_uid character varying(255) NOT NULL,
    office_role_uid character varying(255),
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone,
    checked_at timestamp(3) without time zone,
    office_uid character varying(255) NOT NULL
);


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

CREATE TABLE public.votes (
    uid text NOT NULL,
    appointment_uid character varying(255) NOT NULL,
    voter_uid character varying(255) NOT NULL
);


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

CREATE TABLE public.whitelist (
    uid text NOT NULL,
    email character varying(255) NOT NULL,
    active boolean DEFAULT true NOT NULL,
    created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp(3) without time zone
);


--
-- Name: _prisma_migrations _prisma_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public._prisma_migrations
    ADD CONSTRAINT _prisma_migrations_pkey PRIMARY KEY (id);


--
-- Name: addresses addresses_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.addresses
    ADD CONSTRAINT addresses_pkey PRIMARY KEY (uid);


--
-- Name: appointments appointments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.appointments
    ADD CONSTRAINT appointments_pkey PRIMARY KEY (uid);


--
-- Name: contacts contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.contacts
    ADD CONSTRAINT contacts_pkey PRIMARY KEY (uid);


--
-- Name: customers customers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.customers
    ADD CONSTRAINT customers_pkey PRIMARY KEY (uid);


--
-- Name: deed deed_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deed
    ADD CONSTRAINT deed_pkey PRIMARY KEY (uid);


--
-- Name: deed_types deed_types_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deed_types
    ADD CONSTRAINT deed_types_pkey PRIMARY KEY (uid);


--
-- Name: document_history document_history_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.document_history
    ADD CONSTRAINT document_history_pkey PRIMARY KEY (uid);


--
-- Name: document_types document_types_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.document_types
    ADD CONSTRAINT document_types_pkey PRIMARY KEY (uid);


--
-- Name: documents_notary documents_notary_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.documents_notary
    ADD CONSTRAINT documents_notary_pkey PRIMARY KEY (uid);


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

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


--
-- Name: documents_reminder documents_reminder_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.documents_reminder
    ADD CONSTRAINT documents_reminder_pkey PRIMARY KEY (uid);


--
-- Name: email email_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.email
    ADD CONSTRAINT email_pkey PRIMARY KEY (uid);


--
-- Name: files_notary files_notary_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.files_notary
    ADD CONSTRAINT files_notary_pkey PRIMARY KEY (uid);


--
-- Name: files files_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.files
    ADD CONSTRAINT files_pkey PRIMARY KEY (uid);


--
-- Name: notes notes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notes
    ADD CONSTRAINT notes_pkey PRIMARY KEY (uid);


--
-- Name: notifications notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_pkey PRIMARY KEY (uid);


--
-- Name: office_folder_anchors office_folder_anchors_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.office_folder_anchors
    ADD CONSTRAINT office_folder_anchors_pkey PRIMARY KEY (uid);


--
-- Name: office_folders office_folders_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.office_folders
    ADD CONSTRAINT office_folders_pkey PRIMARY KEY (uid);


--
-- Name: office_roles office_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.office_roles
    ADD CONSTRAINT office_roles_pkey PRIMARY KEY (uid);


--
-- Name: offices offices_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.offices
    ADD CONSTRAINT offices_pkey PRIMARY KEY (uid);


--
-- Name: roles roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.roles
    ADD CONSTRAINT roles_pkey PRIMARY KEY (uid);


--
-- Name: rules_groups rules_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rules_groups
    ADD CONSTRAINT rules_groups_pkey PRIMARY KEY (uid);


--
-- Name: rules rules_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rules
    ADD CONSTRAINT rules_pkey PRIMARY KEY (uid);


--
-- Name: seats seats_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.seats
    ADD CONSTRAINT seats_pkey PRIMARY KEY (uid);


--
-- Name: subscriptions subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subscriptions
    ADD CONSTRAINT subscriptions_pkey PRIMARY KEY (uid);


--
-- Name: totp_codes totp_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.totp_codes
    ADD CONSTRAINT totp_codes_pkey PRIMARY KEY (uid);


--
-- Name: user_notifications user_notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_notifications
    ADD CONSTRAINT user_notifications_pkey PRIMARY KEY (uid);


--
-- Name: user_whitelist user_whitelist_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_whitelist
    ADD CONSTRAINT user_whitelist_pkey PRIMARY KEY (uid);


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

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


--
-- Name: votes votes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.votes
    ADD CONSTRAINT votes_pkey PRIMARY KEY (uid);


--
-- Name: whitelist whitelist_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.whitelist
    ADD CONSTRAINT whitelist_pkey PRIMARY KEY (uid);


--
-- Name: _DeedHasDocumentTypes_AB_unique; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX "_DeedHasDocumentTypes_AB_unique" ON public."_DeedHasDocumentTypes" USING btree ("A", "B");


--
-- Name: _DeedHasDocumentTypes_B_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX "_DeedHasDocumentTypes_B_index" ON public."_DeedHasDocumentTypes" USING btree ("B");


--
-- Name: _DeedTypeHasDocumentTypes_AB_unique; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX "_DeedTypeHasDocumentTypes_AB_unique" ON public."_DeedTypeHasDocumentTypes" USING btree ("A", "B");


--
-- Name: _DeedTypeHasDocumentTypes_B_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX "_DeedTypeHasDocumentTypes_B_index" ON public."_DeedTypeHasDocumentTypes" USING btree ("B");


--
-- Name: _OfficeFolderHasCustomers_AB_unique; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX "_OfficeFolderHasCustomers_AB_unique" ON public."_OfficeFolderHasCustomers" USING btree ("A", "B");


--
-- Name: _OfficeFolderHasCustomers_B_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX "_OfficeFolderHasCustomers_B_index" ON public."_OfficeFolderHasCustomers" USING btree ("B");


--
-- Name: _OfficeFolderHasStakeholders_AB_unique; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX "_OfficeFolderHasStakeholders_AB_unique" ON public."_OfficeFolderHasStakeholders" USING btree ("A", "B");


--
-- Name: _OfficeFolderHasStakeholders_B_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX "_OfficeFolderHasStakeholders_B_index" ON public."_OfficeFolderHasStakeholders" USING btree ("B");


--
-- Name: _OfficeRolesHasRules_AB_unique; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX "_OfficeRolesHasRules_AB_unique" ON public."_OfficeRolesHasRules" USING btree ("A", "B");


--
-- Name: _OfficeRolesHasRules_B_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX "_OfficeRolesHasRules_B_index" ON public."_OfficeRolesHasRules" USING btree ("B");


--
-- Name: _RolesHasRules_AB_unique; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX "_RolesHasRules_AB_unique" ON public."_RolesHasRules" USING btree ("A", "B");


--
-- Name: _RolesHasRules_B_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX "_RolesHasRules_B_index" ON public."_RolesHasRules" USING btree ("B");


--
-- Name: _RulesGroupsHasRules_AB_unique; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX "_RulesGroupsHasRules_AB_unique" ON public."_RulesGroupsHasRules" USING btree ("A", "B");


--
-- Name: _RulesGroupsHasRules_B_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX "_RulesGroupsHasRules_B_index" ON public."_RulesGroupsHasRules" USING btree ("B");


--
-- Name: addresses_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX addresses_uid_key ON public.addresses USING btree (uid);


--
-- Name: appointments_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX appointments_uid_key ON public.appointments USING btree (uid);


--
-- Name: appointments_user_uid_choice_status_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX appointments_user_uid_choice_status_key ON public.appointments USING btree (user_uid, choice, status);


--
-- Name: contacts_address_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX contacts_address_uid_key ON public.contacts USING btree (address_uid);


--
-- Name: contacts_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX contacts_uid_key ON public.contacts USING btree (uid);


--
-- Name: customers_contact_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX customers_contact_uid_key ON public.customers USING btree (contact_uid);


--
-- Name: customers_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX customers_uid_key ON public.customers USING btree (uid);


--
-- Name: deed_types_name_office_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX deed_types_name_office_uid_key ON public.deed_types USING btree (name, office_uid);


--
-- Name: deed_types_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX deed_types_uid_key ON public.deed_types USING btree (uid);


--
-- Name: deed_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX deed_uid_key ON public.deed USING btree (uid);


--
-- Name: document_history_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX document_history_uid_key ON public.document_history USING btree (uid);


--
-- Name: document_types_name_office_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX document_types_name_office_uid_key ON public.document_types USING btree (name, office_uid);


--
-- Name: document_types_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX document_types_uid_key ON public.document_types USING btree (uid);


--
-- Name: documents_notary_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX documents_notary_uid_key ON public.documents_notary USING btree (uid);


--
-- Name: documents_reminder_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX documents_reminder_uid_key ON public.documents_reminder USING btree (uid);


--
-- Name: documents_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX documents_uid_key ON public.documents USING btree (uid);


--
-- Name: email_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX email_uid_key ON public.email USING btree (uid);


--
-- Name: files_file_path_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX files_file_path_key ON public.files USING btree (file_path);


--
-- Name: files_notary_file_path_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX files_notary_file_path_key ON public.files_notary USING btree (file_path);


--
-- Name: files_notary_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX files_notary_uid_key ON public.files_notary USING btree (uid);


--
-- Name: files_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX files_uid_key ON public.files USING btree (uid);


--
-- Name: notes_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX notes_uid_key ON public.notes USING btree (uid);


--
-- Name: notifications_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX notifications_uid_key ON public.notifications USING btree (uid);


--
-- Name: office_folder_anchors_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX office_folder_anchors_uid_key ON public.office_folder_anchors USING btree (uid);


--
-- Name: office_folders_deed_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX office_folders_deed_uid_key ON public.office_folders USING btree (deed_uid);


--
-- Name: office_folders_folder_anchor_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX office_folders_folder_anchor_uid_key ON public.office_folders USING btree (folder_anchor_uid);


--
-- Name: office_folders_folder_number_office_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX office_folders_folder_number_office_uid_key ON public.office_folders USING btree (folder_number, office_uid);


--
-- Name: office_folders_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX office_folders_uid_key ON public.office_folders USING btree (uid);


--
-- Name: office_roles_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX office_roles_uid_key ON public.office_roles USING btree (uid);


--
-- Name: offices_address_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX offices_address_uid_key ON public.offices USING btree (address_uid);


--
-- Name: offices_crpcen_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX offices_crpcen_key ON public.offices USING btree (crpcen);


--
-- Name: offices_idNot_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX "offices_idNot_key" ON public.offices USING btree ("idNot");


--
-- Name: offices_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX offices_uid_key ON public.offices USING btree (uid);


--
-- Name: roles_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX roles_uid_key ON public.roles USING btree (uid);


--
-- Name: rules_groups_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX rules_groups_uid_key ON public.rules_groups USING btree (uid);


--
-- Name: rules_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX rules_uid_key ON public.rules USING btree (uid);


--
-- Name: seats_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX seats_uid_key ON public.seats USING btree (uid);


--
-- Name: subscriptions_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX subscriptions_uid_key ON public.subscriptions USING btree (uid);


--
-- Name: totp_codes_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX totp_codes_uid_key ON public.totp_codes USING btree (uid);


--
-- Name: user_notifications_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX user_notifications_uid_key ON public.user_notifications USING btree (uid);


--
-- Name: user_whitelist_idNot_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX "user_whitelist_idNot_key" ON public.user_whitelist USING btree ("idNot");


--
-- Name: user_whitelist_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX user_whitelist_uid_key ON public.user_whitelist USING btree (uid);


--
-- Name: users_contact_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX users_contact_uid_key ON public.users USING btree (contact_uid);


--
-- Name: users_idNot_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX "users_idNot_key" ON public.users USING btree ("idNot");


--
-- Name: users_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX users_uid_key ON public.users USING btree (uid);


--
-- Name: votes_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX votes_uid_key ON public.votes USING btree (uid);


--
-- Name: whitelist_email_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX whitelist_email_key ON public.whitelist USING btree (email);


--
-- Name: whitelist_uid_key; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX whitelist_uid_key ON public.whitelist USING btree (uid);


--
-- Name: _DeedHasDocumentTypes _DeedHasDocumentTypes_A_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_DeedHasDocumentTypes"
    ADD CONSTRAINT "_DeedHasDocumentTypes_A_fkey" FOREIGN KEY ("A") REFERENCES public.deed(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: _DeedHasDocumentTypes _DeedHasDocumentTypes_B_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_DeedHasDocumentTypes"
    ADD CONSTRAINT "_DeedHasDocumentTypes_B_fkey" FOREIGN KEY ("B") REFERENCES public.document_types(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: _DeedTypeHasDocumentTypes _DeedTypeHasDocumentTypes_A_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_DeedTypeHasDocumentTypes"
    ADD CONSTRAINT "_DeedTypeHasDocumentTypes_A_fkey" FOREIGN KEY ("A") REFERENCES public.deed_types(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: _DeedTypeHasDocumentTypes _DeedTypeHasDocumentTypes_B_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_DeedTypeHasDocumentTypes"
    ADD CONSTRAINT "_DeedTypeHasDocumentTypes_B_fkey" FOREIGN KEY ("B") REFERENCES public.document_types(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: _OfficeFolderHasCustomers _OfficeFolderHasCustomers_A_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_OfficeFolderHasCustomers"
    ADD CONSTRAINT "_OfficeFolderHasCustomers_A_fkey" FOREIGN KEY ("A") REFERENCES public.customers(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: _OfficeFolderHasCustomers _OfficeFolderHasCustomers_B_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_OfficeFolderHasCustomers"
    ADD CONSTRAINT "_OfficeFolderHasCustomers_B_fkey" FOREIGN KEY ("B") REFERENCES public.office_folders(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: _OfficeFolderHasStakeholders _OfficeFolderHasStakeholders_A_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_OfficeFolderHasStakeholders"
    ADD CONSTRAINT "_OfficeFolderHasStakeholders_A_fkey" FOREIGN KEY ("A") REFERENCES public.office_folders(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: _OfficeFolderHasStakeholders _OfficeFolderHasStakeholders_B_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_OfficeFolderHasStakeholders"
    ADD CONSTRAINT "_OfficeFolderHasStakeholders_B_fkey" FOREIGN KEY ("B") REFERENCES public.users(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: _OfficeRolesHasRules _OfficeRolesHasRules_A_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_OfficeRolesHasRules"
    ADD CONSTRAINT "_OfficeRolesHasRules_A_fkey" FOREIGN KEY ("A") REFERENCES public.office_roles(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: _OfficeRolesHasRules _OfficeRolesHasRules_B_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_OfficeRolesHasRules"
    ADD CONSTRAINT "_OfficeRolesHasRules_B_fkey" FOREIGN KEY ("B") REFERENCES public.rules(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: _RolesHasRules _RolesHasRules_A_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_RolesHasRules"
    ADD CONSTRAINT "_RolesHasRules_A_fkey" FOREIGN KEY ("A") REFERENCES public.roles(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: _RolesHasRules _RolesHasRules_B_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_RolesHasRules"
    ADD CONSTRAINT "_RolesHasRules_B_fkey" FOREIGN KEY ("B") REFERENCES public.rules(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: _RulesGroupsHasRules _RulesGroupsHasRules_A_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_RulesGroupsHasRules"
    ADD CONSTRAINT "_RulesGroupsHasRules_A_fkey" FOREIGN KEY ("A") REFERENCES public.rules(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: _RulesGroupsHasRules _RulesGroupsHasRules_B_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."_RulesGroupsHasRules"
    ADD CONSTRAINT "_RulesGroupsHasRules_B_fkey" FOREIGN KEY ("B") REFERENCES public.rules_groups(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: appointments appointments_user_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.appointments
    ADD CONSTRAINT appointments_user_uid_fkey FOREIGN KEY (user_uid) REFERENCES public.users(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: contacts contacts_address_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.contacts
    ADD CONSTRAINT contacts_address_uid_fkey FOREIGN KEY (address_uid) REFERENCES public.addresses(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: customers customers_contact_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.customers
    ADD CONSTRAINT customers_contact_uid_fkey FOREIGN KEY (contact_uid) REFERENCES public.contacts(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: customers customers_office_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.customers
    ADD CONSTRAINT customers_office_uid_fkey FOREIGN KEY (office_uid) REFERENCES public.offices(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: deed deed_deed_type_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deed
    ADD CONSTRAINT deed_deed_type_uid_fkey FOREIGN KEY (deed_type_uid) REFERENCES public.deed_types(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: deed_types deed_types_office_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deed_types
    ADD CONSTRAINT deed_types_office_uid_fkey FOREIGN KEY (office_uid) REFERENCES public.offices(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: document_history document_history_document_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.document_history
    ADD CONSTRAINT document_history_document_uid_fkey FOREIGN KEY (document_uid) REFERENCES public.documents(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: document_types document_types_office_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.document_types
    ADD CONSTRAINT document_types_office_uid_fkey FOREIGN KEY (office_uid) REFERENCES public.offices(uid) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY public.documents
    ADD CONSTRAINT documents_depositor_uid_fkey FOREIGN KEY (depositor_uid) REFERENCES public.customers(uid) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY public.documents
    ADD CONSTRAINT documents_document_type_uid_fkey FOREIGN KEY (document_type_uid) REFERENCES public.document_types(uid) ON UPDATE CASCADE ON DELETE RESTRICT;


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

ALTER TABLE ONLY public.documents
    ADD CONSTRAINT documents_folder_uid_fkey FOREIGN KEY (folder_uid) REFERENCES public.office_folders(uid) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: documents_notary documents_notary_customer_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.documents_notary
    ADD CONSTRAINT documents_notary_customer_uid_fkey FOREIGN KEY (customer_uid) REFERENCES public.customers(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: documents_notary documents_notary_depositor_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.documents_notary
    ADD CONSTRAINT documents_notary_depositor_uid_fkey FOREIGN KEY (depositor_uid) REFERENCES public.users(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: documents_notary documents_notary_folder_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.documents_notary
    ADD CONSTRAINT documents_notary_folder_uid_fkey FOREIGN KEY (folder_uid) REFERENCES public.office_folders(uid) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: documents_reminder documents_reminder_document_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.documents_reminder
    ADD CONSTRAINT documents_reminder_document_uid_fkey FOREIGN KEY (document_uid) REFERENCES public.documents(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: files files_document_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.files
    ADD CONSTRAINT files_document_uid_fkey FOREIGN KEY (document_uid) REFERENCES public.documents(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: files_notary files_notary_document_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.files_notary
    ADD CONSTRAINT files_notary_document_uid_fkey FOREIGN KEY (document_uid) REFERENCES public.documents_notary(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: notes notes_customer_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notes
    ADD CONSTRAINT notes_customer_uid_fkey FOREIGN KEY (customer_uid) REFERENCES public.customers(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: notes notes_folder_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notes
    ADD CONSTRAINT notes_folder_uid_fkey FOREIGN KEY (folder_uid) REFERENCES public.office_folders(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: office_folders office_folders_deed_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.office_folders
    ADD CONSTRAINT office_folders_deed_uid_fkey FOREIGN KEY (deed_uid) REFERENCES public.deed(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: office_folders office_folders_folder_anchor_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.office_folders
    ADD CONSTRAINT office_folders_folder_anchor_uid_fkey FOREIGN KEY (folder_anchor_uid) REFERENCES public.office_folder_anchors(uid) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: office_folders office_folders_office_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.office_folders
    ADD CONSTRAINT office_folders_office_uid_fkey FOREIGN KEY (office_uid) REFERENCES public.offices(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: office_roles office_roles_office_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.office_roles
    ADD CONSTRAINT office_roles_office_uid_fkey FOREIGN KEY (office_uid) REFERENCES public.offices(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: offices offices_address_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.offices
    ADD CONSTRAINT offices_address_uid_fkey FOREIGN KEY (address_uid) REFERENCES public.addresses(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: seats seats_subscription_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.seats
    ADD CONSTRAINT seats_subscription_uid_fkey FOREIGN KEY (subscription_uid) REFERENCES public.subscriptions(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: seats seats_user_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.seats
    ADD CONSTRAINT seats_user_uid_fkey FOREIGN KEY (user_uid) REFERENCES public.users(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: subscriptions subscriptions_office_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subscriptions
    ADD CONSTRAINT subscriptions_office_uid_fkey FOREIGN KEY (office_uid) REFERENCES public.offices(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: totp_codes totp_codes_customer_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.totp_codes
    ADD CONSTRAINT totp_codes_customer_uid_fkey FOREIGN KEY (customer_uid) REFERENCES public.customers(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: user_notifications user_notifications_notification_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_notifications
    ADD CONSTRAINT user_notifications_notification_uid_fkey FOREIGN KEY (notification_uid) REFERENCES public.notifications(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: user_notifications user_notifications_user_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_notifications
    ADD CONSTRAINT user_notifications_user_uid_fkey FOREIGN KEY (user_uid) REFERENCES public.users(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: users users_contact_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_contact_uid_fkey FOREIGN KEY (contact_uid) REFERENCES public.contacts(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: users users_office_role_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_office_role_uid_fkey FOREIGN KEY (office_role_uid) REFERENCES public.office_roles(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: users users_office_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_office_uid_fkey FOREIGN KEY (office_uid) REFERENCES public.offices(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: users users_roles_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_roles_uid_fkey FOREIGN KEY (roles_uid) REFERENCES public.roles(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: votes votes_appointment_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.votes
    ADD CONSTRAINT votes_appointment_uid_fkey FOREIGN KEY (appointment_uid) REFERENCES public.appointments(uid) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: votes votes_voter_uid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.votes
    ADD CONSTRAINT votes_voter_uid_fkey FOREIGN KEY (voter_uid) REFERENCES public.users(uid) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- PostgreSQL database dump complete
--


