--
-- PostgreSQL database dump
--

-- Dumped from database version 9.6.10
-- Dumped by pg_dump version 11.2

-- Started on 2020-05-12 17:07:27

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_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 client_min_messages = warning;
SET row_security = off;

--
-- TOC entry 2 (class 3079 OID 18451)
-- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: 
--

CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;


--
-- TOC entry 2477 (class 0 OID 0)
-- Dependencies: 2
-- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';


SET default_tablespace = '';

SET default_with_oids = false;

--
-- TOC entry 186 (class 1259 OID 37851)
-- Name: Content; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."Content" (
    "Id" uuid NOT NULL,
    "Filename" character varying NOT NULL,
    "Extension" character varying NOT NULL,
    "ParentType" numeric NOT NULL,
    "Uri" character varying NOT NULL,
    "LocationType" numeric NOT NULL
);


ALTER TABLE public."Content" OWNER TO :POSTGRES_USER;

--
-- TOC entry 187 (class 1259 OID 37857)
-- Name: Credential; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."Credential" (
    "Id" uuid NOT NULL,
    "Status" numeric NOT NULL,
    "Provider" numeric NOT NULL,
    "Public" character varying NOT NULL,
    "Secret" character varying NOT NULL,
    "CreationTime" date NOT NULL,
    "LastUpdateTime" date NOT NULL,
    "UserId" uuid NOT NULL,
    "ExternalId" character varying NOT NULL
);


ALTER TABLE public."Credential" OWNER TO :POSTGRES_USER;

--
-- TOC entry 218 (class 1259 OID 46438)
-- Name: DBVersion; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DBVersion" (
    key character varying NOT NULL,
    version character varying NOT NULL,
    "releasedAt" timestamp with time zone NOT NULL,
    "deployedAt" timestamp with time zone,
    description text
);


ALTER TABLE public."DBVersion" OWNER TO :POSTGRES_USER;

--
-- TOC entry 188 (class 1259 OID 37863)
-- Name: DMP; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DMP" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "GroupId" uuid,
    "Label" character varying(250) NOT NULL,
    "Version" integer NOT NULL,
    "Grant" uuid NOT NULL,
    "AssociatedDmps" xml,
    "Profile" uuid,
    "Status" smallint DEFAULT 0 NOT NULL,
    "Created" timestamp without time zone DEFAULT now() NOT NULL,
    "Modified" timestamp without time zone DEFAULT now() NOT NULL,
    "Description" text,
    "Creator" uuid,
    "Properties" text,
    "DmpProperties" text,
    "FinalizedAt" timestamp(6) with time zone,
    "isPublic" boolean DEFAULT false NOT NULL,
    "PublishedAt" timestamp(6) with time zone,
    "DOI" text,
    "Project" uuid
);


ALTER TABLE public."DMP" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2478 (class 0 OID 0)
-- Dependencies: 188
-- Name: COLUMN "DMP"."AssociatedDmps"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."DMP"."AssociatedDmps" IS 'More data about the DMP as defined by the profile';


--
-- TOC entry 212 (class 1259 OID 38303)
-- Name: DMPDatasetProfile; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DMPDatasetProfile" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    dmp uuid NOT NULL,
    datasetprofile uuid NOT NULL
);


ALTER TABLE public."DMPDatasetProfile" OWNER TO :POSTGRES_USER;

--
-- TOC entry 189 (class 1259 OID 37873)
-- Name: DMPOrganisation; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DMPOrganisation" (
    "DMP" uuid NOT NULL,
    "Organisation" uuid NOT NULL,
    "Role" integer,
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL
);


ALTER TABLE public."DMPOrganisation" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2479 (class 0 OID 0)
-- Dependencies: 189
-- Name: TABLE "DMPOrganisation"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON TABLE public."DMPOrganisation" IS 'Linking of DMPs to Organisations';


--
-- TOC entry 2480 (class 0 OID 0)
-- Dependencies: 189
-- Name: COLUMN "DMPOrganisation"."Role"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."DMPOrganisation"."Role" IS 'Enumerator of roles';


--
-- TOC entry 190 (class 1259 OID 37877)
-- Name: DMPProfile; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DMPProfile" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying(250) NOT NULL,
    "Definition" xml,
    "Status" smallint DEFAULT 0 NOT NULL,
    "Created" timestamp without time zone DEFAULT now() NOT NULL,
    "Modified" timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public."DMPProfile" OWNER TO :POSTGRES_USER;

--
-- TOC entry 191 (class 1259 OID 37887)
-- Name: DMPResearcher; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DMPResearcher" (
    "DMP" uuid NOT NULL,
    "Researcher" uuid NOT NULL,
    "Role" integer,
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL
);


ALTER TABLE public."DMPResearcher" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2481 (class 0 OID 0)
-- Dependencies: 191
-- Name: TABLE "DMPResearcher"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON TABLE public."DMPResearcher" IS 'Linking of DMPs to researchers';


--
-- TOC entry 2482 (class 0 OID 0)
-- Dependencies: 191
-- Name: COLUMN "DMPResearcher"."Role"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."DMPResearcher"."Role" IS 'Enumerator of roles';


--
-- TOC entry 192 (class 1259 OID 37891)
-- Name: DataRepository; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DataRepository" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying(250),
    "Abbreviation" character varying(50),
    "Reference" character varying,
    "Uri" character varying(250),
    "Definition" xml,
    "Status" smallint DEFAULT 0 NOT NULL,
    "Created" timestamp without time zone DEFAULT now() NOT NULL,
    "Modified" timestamp without time zone DEFAULT now() NOT NULL,
    "CreationUser" uuid
);


ALTER TABLE public."DataRepository" OWNER TO :POSTGRES_USER;

--
-- TOC entry 193 (class 1259 OID 37901)
-- Name: Dataset; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."Dataset" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying(250) NOT NULL,
    "DMP" uuid,
    "Uri" character varying(250),
    "Properties" text,
    "Profile" uuid,
    "Reference" text,
    "Status" smallint DEFAULT 0 NOT NULL,
    "Created" timestamp without time zone DEFAULT now() NOT NULL,
    "Modified" timestamp without time zone DEFAULT now() NOT NULL,
    "Description" text,
    "Creator" uuid,
    "FinalizedAt" timestamp(6) with time zone
);


ALTER TABLE public."Dataset" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2483 (class 0 OID 0)
-- Dependencies: 193
-- Name: COLUMN "Dataset"."Uri"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Dataset"."Uri" IS 'URI of item';


--
-- TOC entry 2484 (class 0 OID 0)
-- Dependencies: 193
-- Name: COLUMN "Dataset"."Properties"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Dataset"."Properties" IS 'More data about the dataset such as Uri, data types etc as defined by the profile';


--
-- TOC entry 194 (class 1259 OID 37912)
-- Name: DatasetDataRepository; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DatasetDataRepository" (
    "Dataset" uuid NOT NULL,
    "DataRepository" uuid NOT NULL,
    "Role" integer,
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Data" character varying
);


ALTER TABLE public."DatasetDataRepository" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2485 (class 0 OID 0)
-- Dependencies: 194
-- Name: TABLE "DatasetDataRepository"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON TABLE public."DatasetDataRepository" IS 'Linking Dataset to DataRepository';


--
-- TOC entry 195 (class 1259 OID 37916)
-- Name: DatasetExternalDataset; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DatasetExternalDataset" (
    "Id" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Dataset" uuid NOT NULL,
    "ExternalDataset" uuid NOT NULL,
    "Role" numeric,
    "Data" character varying
);


ALTER TABLE public."DatasetExternalDataset" OWNER TO :POSTGRES_USER;

--
-- TOC entry 196 (class 1259 OID 37923)
-- Name: DatasetProfile; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DatasetProfile" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying(250) NOT NULL,
    "Definition" xml NOT NULL,
    "Status" smallint DEFAULT 0 NOT NULL,
    "Created" timestamp without time zone DEFAULT now() NOT NULL,
    "Modified" timestamp without time zone DEFAULT now() NOT NULL,
    "Description" text NOT NULL,
    "GroupId" uuid DEFAULT public.uuid_generate_v1() NOT NULL,
    "Version" integer DEFAULT 0 NOT NULL
);


ALTER TABLE public."DatasetProfile" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2486 (class 0 OID 0)
-- Dependencies: 196
-- Name: TABLE "DatasetProfile"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON TABLE public."DatasetProfile" IS 'Profiles for dmp datasets';


--
-- TOC entry 197 (class 1259 OID 37933)
-- Name: DatasetProfileRuleset; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DatasetProfileRuleset" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying(250) NOT NULL,
    "Definition" xml NOT NULL
);


ALTER TABLE public."DatasetProfileRuleset" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2487 (class 0 OID 0)
-- Dependencies: 197
-- Name: TABLE "DatasetProfileRuleset"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON TABLE public."DatasetProfileRuleset" IS 'Sets of Rules for dmp dataset profiles';


--
-- TOC entry 198 (class 1259 OID 37940)
-- Name: DatasetProfileViewstyle; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DatasetProfileViewstyle" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying(250) NOT NULL,
    "Definition" xml NOT NULL
);


ALTER TABLE public."DatasetProfileViewstyle" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2488 (class 0 OID 0)
-- Dependencies: 198
-- Name: TABLE "DatasetProfileViewstyle"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON TABLE public."DatasetProfileViewstyle" IS 'Style sets for dmp dataset profiles';


--
-- TOC entry 199 (class 1259 OID 37947)
-- Name: DatasetRegistry; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DatasetRegistry" (
    "Dataset" uuid NOT NULL,
    "Registry" uuid NOT NULL,
    "Role" integer,
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Data" character varying
);


ALTER TABLE public."DatasetRegistry" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2489 (class 0 OID 0)
-- Dependencies: 199
-- Name: TABLE "DatasetRegistry"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON TABLE public."DatasetRegistry" IS 'Linking Dataset to Registry';


--
-- TOC entry 200 (class 1259 OID 37951)
-- Name: DatasetService; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DatasetService" (
    "Dataset" uuid NOT NULL,
    "Service" uuid NOT NULL,
    "Role" integer,
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Data" character varying
);


ALTER TABLE public."DatasetService" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2490 (class 0 OID 0)
-- Dependencies: 200
-- Name: TABLE "DatasetService"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON TABLE public."DatasetService" IS 'Linking Dataset to Service';


--
-- TOC entry 220 (class 1259 OID 46459)
-- Name: DoiFunder; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."DoiFunder" (
    id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    name character varying,
    doi character varying
);


ALTER TABLE public."DoiFunder" OWNER TO :POSTGRES_USER;

--
-- TOC entry 201 (class 1259 OID 37955)
-- Name: ExternalDataset; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."ExternalDataset" (
    "Id" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying NOT NULL,
    "Abbreviation" character varying,
    "Reference" character varying NOT NULL,
    "Created" date NOT NULL,
    "Modified" date NOT NULL,
    "CreationUser" uuid
);


ALTER TABLE public."ExternalDataset" OWNER TO :POSTGRES_USER;

--
-- TOC entry 214 (class 1259 OID 38352)
-- Name: Funder; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."Funder" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying(250) NOT NULL,
    "Reference" character varying,
    "Definition" character varying,
    "Status" smallint DEFAULT 0 NOT NULL,
    "Created" timestamp(4) with time zone DEFAULT now() NOT NULL,
    "Modified" timestamp(4) with time zone DEFAULT now() NOT NULL,
    "Type" numeric DEFAULT 0 NOT NULL,
    "CreationUser" uuid
);


ALTER TABLE public."Funder" OWNER TO :POSTGRES_USER;

--
-- TOC entry 204 (class 1259 OID 37978)
-- Name: Grant; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."Grant" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying(250) NOT NULL,
    "Abbreviation" character varying(50),
    "Reference" character varying,
    "Uri" character varying(250),
    "Definition" character varying,
    "Status" smallint DEFAULT 0 NOT NULL,
    "Created" timestamp without time zone DEFAULT now() NOT NULL,
    "Modified" timestamp without time zone DEFAULT now() NOT NULL,
    "StartDate" timestamp without time zone,
    "EndDate" timestamp without time zone,
    "Description" text,
    "CreationUser" uuid DEFAULT '332ffc36-bd51-4d4e-bf9a-ffb01fdee05a'::uuid,
    "Type" numeric DEFAULT 0 NOT NULL,
    "Content" uuid,
    "Funder" uuid
);


ALTER TABLE public."Grant" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2491 (class 0 OID 0)
-- Dependencies: 204
-- Name: TABLE "Grant"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON TABLE public."Grant" IS 'Table of project managed in the system';


--
-- TOC entry 2492 (class 0 OID 0)
-- Dependencies: 204
-- Name: COLUMN "Grant"."ID"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Grant"."ID" IS 'Unique identifier and primary key of item';


--
-- TOC entry 2493 (class 0 OID 0)
-- Dependencies: 204
-- Name: COLUMN "Grant"."Label"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Grant"."Label" IS 'A human readable long label of the item';


--
-- TOC entry 2494 (class 0 OID 0)
-- Dependencies: 204
-- Name: COLUMN "Grant"."Abbreviation"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Grant"."Abbreviation" IS 'A human readable abbreviation of the item';


--
-- TOC entry 2495 (class 0 OID 0)
-- Dependencies: 204
-- Name: COLUMN "Grant"."Reference"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Grant"."Reference" IS 'Additional reference data for the item along with information to allow how the item reached the system (e.g. via an external vocabulary)';


--
-- TOC entry 2496 (class 0 OID 0)
-- Dependencies: 204
-- Name: COLUMN "Grant"."Uri"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Grant"."Uri" IS 'URI of item';


--
-- TOC entry 2497 (class 0 OID 0)
-- Dependencies: 204
-- Name: COLUMN "Grant"."Definition"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Grant"."Definition" IS 'More data about the project such as web site, start/stop, etc';


--
-- TOC entry 202 (class 1259 OID 37962)
-- Name: Invitation; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."Invitation" (
    "Id" uuid NOT NULL,
    "InvitationEmail" character varying NOT NULL,
    "Token" uuid NOT NULL,
    "CreationUser" uuid NOT NULL,
    "Dmp" uuid NOT NULL,
    "Properties" xml,
    "AcceptedInvitation" boolean
);


ALTER TABLE public."Invitation" OWNER TO :POSTGRES_USER;

--
-- TOC entry 216 (class 1259 OID 38423)
-- Name: Lock; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."Lock" (
    id uuid NOT NULL,
    "Target" uuid NOT NULL,
    "LockedBy" uuid NOT NULL,
    "LockedAt" timestamp without time zone NOT NULL,
    "TouchedAt" timestamp without time zone
);


ALTER TABLE public."Lock" OWNER TO :POSTGRES_USER;

--
-- TOC entry 213 (class 1259 OID 38343)
-- Name: LoginConfirmationEmail; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."LoginConfirmationEmail" (
    "ID" uuid NOT NULL,
    email character varying NOT NULL,
    "isConfirmed" boolean NOT NULL,
    token uuid NOT NULL,
    "userId" uuid NOT NULL,
    "expiresAt" timestamp(4) with time zone NOT NULL
);


ALTER TABLE public."LoginConfirmationEmail" OWNER TO :POSTGRES_USER;

--
-- TOC entry 217 (class 1259 OID 38433)
-- Name: Notification; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."Notification" (
    id uuid NOT NULL,
    "UserId" uuid,
    "IsActive" integer NOT NULL,
    "Type" integer NOT NULL,
    "ContactTypeHint" integer,
    "ContactHint" character varying,
    "Data" character varying,
    "NotifyState" integer NOT NULL,
    "NotifiedAt" timestamp without time zone,
    "RetryCount" integer,
    "CreatedAt" timestamp without time zone,
    "UpdatedAt" timestamp without time zone
);


ALTER TABLE public."Notification" OWNER TO :POSTGRES_USER;

--
-- TOC entry 203 (class 1259 OID 37968)
-- Name: Organisation; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."Organisation" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying(250) NOT NULL,
    "Abbreviation" character varying(50),
    "Reference" character varying,
    "Uri" character varying(250),
    "Definition" xml,
    "Status" smallint DEFAULT 0 NOT NULL,
    "Created" timestamp without time zone DEFAULT now() NOT NULL,
    "Modified" timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public."Organisation" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2498 (class 0 OID 0)
-- Dependencies: 203
-- Name: TABLE "Organisation"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON TABLE public."Organisation" IS 'Table of organizations utilized in the project';


--
-- TOC entry 2499 (class 0 OID 0)
-- Dependencies: 203
-- Name: COLUMN "Organisation"."ID"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Organisation"."ID" IS 'Unique identifier and primary key of item';


--
-- TOC entry 2500 (class 0 OID 0)
-- Dependencies: 203
-- Name: COLUMN "Organisation"."Label"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Organisation"."Label" IS 'A human readable long label of the item';


--
-- TOC entry 2501 (class 0 OID 0)
-- Dependencies: 203
-- Name: COLUMN "Organisation"."Abbreviation"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Organisation"."Abbreviation" IS 'A human readable abbreviation of the item';


--
-- TOC entry 2502 (class 0 OID 0)
-- Dependencies: 203
-- Name: COLUMN "Organisation"."Reference"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Organisation"."Reference" IS 'Reference to the URI of the item along with information to allow how the item reached the system (e.g. via an external vocabulary)';


--
-- TOC entry 2503 (class 0 OID 0)
-- Dependencies: 203
-- Name: COLUMN "Organisation"."Uri"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Organisation"."Uri" IS 'URI of item';


--
-- TOC entry 2504 (class 0 OID 0)
-- Dependencies: 203
-- Name: COLUMN "Organisation"."Definition"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Organisation"."Definition" IS 'More data about the Organisation such as web site, type etc';


--
-- TOC entry 215 (class 1259 OID 38365)
-- Name: Project; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."Project" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying(250) NOT NULL,
    "Abbreviation" character varying(50),
    "Reference" character varying,
    "Uri" character varying(250),
    "Definition" character varying,
    "Status" smallint DEFAULT 0 NOT NULL,
    "Created" timestamp(4) with time zone DEFAULT now() NOT NULL,
    "Modified" timestamp(4) with time zone DEFAULT now() NOT NULL,
    "StartDate" timestamp(4) with time zone,
    "EndDate" timestamp(4) with time zone,
    "Description" text,
    "CreationUser" uuid,
    "Type" numeric DEFAULT 0 NOT NULL,
    "Content" uuid
);


ALTER TABLE public."Project" OWNER TO :POSTGRES_USER;

--
-- TOC entry 205 (class 1259 OID 37990)
-- Name: Registry; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."Registry" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying(250),
    "Abbreviation" character varying(50),
    "Reference" character varying,
    "Uri" character varying(250),
    "Definition" xml,
    "Status" smallint DEFAULT 0 NOT NULL,
    "Created" timestamp without time zone DEFAULT now() NOT NULL,
    "Modified" timestamp without time zone DEFAULT now() NOT NULL,
    "CreationUser" uuid
);


ALTER TABLE public."Registry" OWNER TO :POSTGRES_USER;

--
-- TOC entry 206 (class 1259 OID 38000)
-- Name: Researcher; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."Researcher" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying(250) NOT NULL,
    "Uri" character varying(250),
    "PrimaryEmail" character varying(250),
    "Definition" xml,
    "Reference" character varying,
    "Status" smallint DEFAULT 0 NOT NULL,
    "Created" timestamp without time zone DEFAULT now() NOT NULL,
    "Modified" timestamp without time zone DEFAULT now() NOT NULL,
    "CreationUser" uuid
);


ALTER TABLE public."Researcher" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2505 (class 0 OID 0)
-- Dependencies: 206
-- Name: TABLE "Researcher"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON TABLE public."Researcher" IS 'Table of Researcher managed in the system';


--
-- TOC entry 2506 (class 0 OID 0)
-- Dependencies: 206
-- Name: COLUMN "Researcher"."ID"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Researcher"."ID" IS 'Unique identifier and primary key of item';


--
-- TOC entry 2507 (class 0 OID 0)
-- Dependencies: 206
-- Name: COLUMN "Researcher"."Label"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Researcher"."Label" IS 'Full name of the researcher (as presented by the system, and composed automatically by data or provided by the reference service)';


--
-- TOC entry 2508 (class 0 OID 0)
-- Dependencies: 206
-- Name: COLUMN "Researcher"."Uri"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Researcher"."Uri" IS 'URI of item';


--
-- TOC entry 2509 (class 0 OID 0)
-- Dependencies: 206
-- Name: COLUMN "Researcher"."Definition"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Researcher"."Definition" IS 'More data about the researcher such as: email addresses, affiliations etc';


--
-- TOC entry 2510 (class 0 OID 0)
-- Dependencies: 206
-- Name: COLUMN "Researcher"."Reference"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."Researcher"."Reference" IS 'Additional reference data for the item along with information to allow how the item reached the system (e.g. via an external vocabulary)';


--
-- TOC entry 207 (class 1259 OID 38010)
-- Name: Service; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."Service" (
    "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Label" character varying(250),
    "Abbreviation" character varying(50),
    "Reference" character varying,
    "Uri" character varying(250),
    "Definition" xml,
    "Status" smallint DEFAULT 0 NOT NULL,
    "Created" timestamp without time zone DEFAULT now() NOT NULL,
    "Modified" timestamp without time zone DEFAULT now() NOT NULL,
    "CreationUser" uuid
);


ALTER TABLE public."Service" OWNER TO :POSTGRES_USER;

--
-- TOC entry 219 (class 1259 OID 46444)
-- Name: UserAssociation; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."UserAssociation" (
    id uuid NOT NULL,
    "firstUser" uuid NOT NULL,
    "secondUser" uuid NOT NULL
);


ALTER TABLE public."UserAssociation" OWNER TO :POSTGRES_USER;

--
-- TOC entry 208 (class 1259 OID 38020)
-- Name: UserDMP; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."UserDMP" (
    id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    usr uuid NOT NULL,
    dmp uuid NOT NULL,
    role integer
);


ALTER TABLE public."UserDMP" OWNER TO :POSTGRES_USER;

--
-- TOC entry 209 (class 1259 OID 38024)
-- Name: UserInfo; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."UserInfo" (
    id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    email character varying(250),
    authorization_level smallint NOT NULL,
    usertype smallint NOT NULL,
    verified_email boolean,
    name character varying(250),
    created timestamp without time zone,
    lastloggedin timestamp without time zone,
    additionalinfo json
);


ALTER TABLE public."UserInfo" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2511 (class 0 OID 0)
-- Dependencies: 209
-- Name: COLUMN "UserInfo".authorization_level; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."UserInfo".authorization_level IS 'This stores the authorization level of the user: 0 admin, 1 user, being able to be extended furthermore';


--
-- TOC entry 2512 (class 0 OID 0)
-- Dependencies: 209
-- Name: COLUMN "UserInfo".usertype; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
--

COMMENT ON COLUMN public."UserInfo".usertype IS 'This stores the type of user: 0 -> internal, 1 external';


--
-- TOC entry 210 (class 1259 OID 38031)
-- Name: UserRole; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."UserRole" (
    "Id" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    "Role" numeric DEFAULT 0 NOT NULL,
    "UserId" uuid NOT NULL
);


ALTER TABLE public."UserRole" OWNER TO :POSTGRES_USER;

--
-- TOC entry 211 (class 1259 OID 38039)
-- Name: UserToken; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--

CREATE TABLE public."UserToken" (
    "Token" uuid NOT NULL,
    "UserId" uuid NOT NULL,
    "IssuedAt" date NOT NULL,
    "ExpiresAt" date NOT NULL
);


ALTER TABLE public."UserToken" OWNER TO :POSTGRES_USER;

--
-- TOC entry 2251 (class 2606 OID 38044)
-- Name: Content Content_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Content"
    ADD CONSTRAINT "Content_pkey" PRIMARY KEY ("Id");


--
-- TOC entry 2253 (class 2606 OID 38046)
-- Name: Credential Credential_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Credential"
    ADD CONSTRAINT "Credential_pkey" PRIMARY KEY ("Id");


--
-- TOC entry 2305 (class 2606 OID 38308)
-- Name: DMPDatasetProfile DMPDatasetProfile_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMPDatasetProfile"
    ADD CONSTRAINT "DMPDatasetProfile_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2260 (class 2606 OID 38048)
-- Name: DMPProfile DMPPRofile_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMPProfile"
    ADD CONSTRAINT "DMPPRofile_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2255 (class 2606 OID 38050)
-- Name: DMP DMP_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMP"
    ADD CONSTRAINT "DMP_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2269 (class 2606 OID 38246)
-- Name: DatasetDataRepository DatasetDataRepository_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetDataRepository"
    ADD CONSTRAINT "DatasetDataRepository_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2271 (class 2606 OID 38052)
-- Name: DatasetExternalDataset DatasetExternalDataset_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetExternalDataset"
    ADD CONSTRAINT "DatasetExternalDataset_pkey" PRIMARY KEY ("Id");


--
-- TOC entry 2275 (class 2606 OID 38054)
-- Name: DatasetProfileRuleset DatasetProfileRuleset_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetProfileRuleset"
    ADD CONSTRAINT "DatasetProfileRuleset_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2277 (class 2606 OID 38056)
-- Name: DatasetProfileViewstyle DatasetProfileViewstyle_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetProfileViewstyle"
    ADD CONSTRAINT "DatasetProfileViewstyle_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2273 (class 2606 OID 38058)
-- Name: DatasetProfile DatasetProfile_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetProfile"
    ADD CONSTRAINT "DatasetProfile_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2279 (class 2606 OID 38249)
-- Name: DatasetRegistry DatasetRegistry_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetRegistry"
    ADD CONSTRAINT "DatasetRegistry_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2281 (class 2606 OID 38252)
-- Name: DatasetService DatasetService_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetService"
    ADD CONSTRAINT "DatasetService_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2266 (class 2606 OID 38060)
-- Name: Dataset Dataset_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Dataset"
    ADD CONSTRAINT "Dataset_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2319 (class 2606 OID 46467)
-- Name: DoiFunder DoiFunder_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DoiFunder"
    ADD CONSTRAINT "DoiFunder_pkey" PRIMARY KEY (id);


--
-- TOC entry 2283 (class 2606 OID 38062)
-- Name: ExternalDataset ExternalDataset_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."ExternalDataset"
    ADD CONSTRAINT "ExternalDataset_pkey" PRIMARY KEY ("Id");


--
-- TOC entry 2309 (class 2606 OID 38364)
-- Name: Funder Funder_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Funder"
    ADD CONSTRAINT "Funder_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2289 (class 2606 OID 38078)
-- Name: Grant Grant_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Grant"
    ADD CONSTRAINT "Grant_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2285 (class 2606 OID 38064)
-- Name: Invitation Invitation_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Invitation"
    ADD CONSTRAINT "Invitation_pkey" PRIMARY KEY ("Id");


--
-- TOC entry 2313 (class 2606 OID 38427)
-- Name: Lock Lock_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Lock"
    ADD CONSTRAINT "Lock_pkey" PRIMARY KEY (id);


--
-- TOC entry 2307 (class 2606 OID 38350)
-- Name: LoginConfirmationEmail LoginConfirmationEmail_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."LoginConfirmationEmail"
    ADD CONSTRAINT "LoginConfirmationEmail_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2315 (class 2606 OID 38440)
-- Name: Notification Notification_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Notification"
    ADD CONSTRAINT "Notification_pkey" PRIMARY KEY (id);


--
-- TOC entry 2287 (class 2606 OID 38066)
-- Name: Organisation Organisation_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Organisation"
    ADD CONSTRAINT "Organisation_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2258 (class 2606 OID 38068)
-- Name: DMPOrganisation PKey_DMPOrganisation; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMPOrganisation"
    ADD CONSTRAINT "PKey_DMPOrganisation" PRIMARY KEY ("ID");


--
-- TOC entry 2262 (class 2606 OID 38070)
-- Name: DMPResearcher PKey_DMPResearcher; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMPResearcher"
    ADD CONSTRAINT "PKey_DMPResearcher" PRIMARY KEY ("ID");


--
-- TOC entry 2264 (class 2606 OID 38072)
-- Name: DataRepository PKey_DataRepository; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DataRepository"
    ADD CONSTRAINT "PKey_DataRepository" PRIMARY KEY ("ID");


--
-- TOC entry 2291 (class 2606 OID 38074)
-- Name: Registry PKey_Registry; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Registry"
    ADD CONSTRAINT "PKey_Registry" PRIMARY KEY ("ID");


--
-- TOC entry 2295 (class 2606 OID 38076)
-- Name: Service PKey_Service; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Service"
    ADD CONSTRAINT "PKey_Service" PRIMARY KEY ("ID");


--
-- TOC entry 2311 (class 2606 OID 38377)
-- Name: Project Project_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Project"
    ADD CONSTRAINT "Project_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2293 (class 2606 OID 38080)
-- Name: Researcher Researcher_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Researcher"
    ADD CONSTRAINT "Researcher_pkey" PRIMARY KEY ("ID");


--
-- TOC entry 2297 (class 2606 OID 38082)
-- Name: UserInfo UserInfo_email_key; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."UserInfo"
    ADD CONSTRAINT "UserInfo_email_key" UNIQUE (email);


--
-- TOC entry 2299 (class 2606 OID 38084)
-- Name: UserInfo UserInfo_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."UserInfo"
    ADD CONSTRAINT "UserInfo_pkey" PRIMARY KEY (id);


--
-- TOC entry 2301 (class 2606 OID 38086)
-- Name: UserRole UserRole_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."UserRole"
    ADD CONSTRAINT "UserRole_pkey" PRIMARY KEY ("Id");


--
-- TOC entry 2303 (class 2606 OID 38088)
-- Name: UserToken UserToken_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."UserToken"
    ADD CONSTRAINT "UserToken_pkey" PRIMARY KEY ("Token");


--
-- TOC entry 2317 (class 2606 OID 46448)
-- Name: UserAssociation [REDACTED] Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."UserAssociation"
    ADD CONSTRAINT [REDACTED]PRIMARY KEY (id);


--
-- TOC entry 2256 (class 1259 OID 38089)
-- Name: fki_DMPDMPProfileReference; Type: INDEX; Schema: public; Owner: :POSTGRES_USER
--

CREATE INDEX "fki_DMPDMPProfileReference" ON public."DMP" USING btree ("Profile");


--
-- TOC entry 2267 (class 1259 OID 38090)
-- Name: fki_DatasetDatasetProfileReference; Type: INDEX; Schema: public; Owner: :POSTGRES_USER
--

CREATE INDEX "fki_DatasetDatasetProfileReference" ON public."Dataset" USING btree ("Profile");


--
-- TOC entry 2321 (class 2606 OID 38091)
-- Name: DMP DMPDMPProfileReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMP"
    ADD CONSTRAINT "DMPDMPProfileReference" FOREIGN KEY ("Profile") REFERENCES public."DMPProfile"("ID");


--
-- TOC entry 2347 (class 2606 OID 38309)
-- Name: DMPDatasetProfile DMPDatasetProfile_datasetprofile_fkey; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMPDatasetProfile"
    ADD CONSTRAINT "DMPDatasetProfile_datasetprofile_fkey" FOREIGN KEY (datasetprofile) REFERENCES public."DatasetProfile"("ID");


--
-- TOC entry 2348 (class 2606 OID 38314)
-- Name: DMPDatasetProfile DMPDatasetProfile_dmp_fkey; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMPDatasetProfile"
    ADD CONSTRAINT "DMPDatasetProfile_dmp_fkey" FOREIGN KEY (dmp) REFERENCES public."DMP"("ID");


--
-- TOC entry 2324 (class 2606 OID 38096)
-- Name: DMPOrganisation DMPOrganisationDMPReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMPOrganisation"
    ADD CONSTRAINT "DMPOrganisationDMPReference" FOREIGN KEY ("Organisation") REFERENCES public."Organisation"("ID");


--
-- TOC entry 2325 (class 2606 OID 38101)
-- Name: DMPOrganisation DMPOrganisationOrganisationReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMPOrganisation"
    ADD CONSTRAINT "DMPOrganisationOrganisationReference" FOREIGN KEY ("DMP") REFERENCES public."DMP"("ID");


--
-- TOC entry 2322 (class 2606 OID 38106)
-- Name: DMP DMPProjectReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMP"
    ADD CONSTRAINT "DMPProjectReference" FOREIGN KEY ("Grant") REFERENCES public."Grant"("ID");


--
-- TOC entry 2326 (class 2606 OID 38111)
-- Name: DMPResearcher DMPResearcherDMPReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMPResearcher"
    ADD CONSTRAINT "DMPResearcherDMPReference" FOREIGN KEY ("Researcher") REFERENCES public."Researcher"("ID");


--
-- TOC entry 2327 (class 2606 OID 38116)
-- Name: DMPResearcher DMPResearcherResearcherReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMPResearcher"
    ADD CONSTRAINT "DMPResearcherResearcherReference" FOREIGN KEY ("DMP") REFERENCES public."DMP"("ID");


--
-- TOC entry 2328 (class 2606 OID 38121)
-- Name: Dataset DatasetDMPReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Dataset"
    ADD CONSTRAINT "DatasetDMPReference" FOREIGN KEY ("DMP") REFERENCES public."DMP"("ID");


--
-- TOC entry 2331 (class 2606 OID 38126)
-- Name: DatasetDataRepository DatasetDataRepositoryDataRepositoryReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetDataRepository"
    ADD CONSTRAINT "DatasetDataRepositoryDataRepositoryReference" FOREIGN KEY ("DataRepository") REFERENCES public."DataRepository"("ID");


--
-- TOC entry 2332 (class 2606 OID 38131)
-- Name: DatasetDataRepository DatasetDataRepositoryDatasetReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetDataRepository"
    ADD CONSTRAINT "DatasetDataRepositoryDatasetReference" FOREIGN KEY ("Dataset") REFERENCES public."Dataset"("ID");


--
-- TOC entry 2329 (class 2606 OID 38136)
-- Name: Dataset DatasetDatasetProfileReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Dataset"
    ADD CONSTRAINT "DatasetDatasetProfileReference" FOREIGN KEY ("Profile") REFERENCES public."DatasetProfile"("ID");


--
-- TOC entry 2335 (class 2606 OID 38141)
-- Name: DatasetRegistry DatasetRegistryDatasetReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetRegistry"
    ADD CONSTRAINT "DatasetRegistryDatasetReference" FOREIGN KEY ("Dataset") REFERENCES public."Dataset"("ID");


--
-- TOC entry 2336 (class 2606 OID 38146)
-- Name: DatasetRegistry DatasetRegistryRegistryReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetRegistry"
    ADD CONSTRAINT "DatasetRegistryRegistryReference" FOREIGN KEY ("Registry") REFERENCES public."Registry"("ID");


--
-- TOC entry 2337 (class 2606 OID 38151)
-- Name: DatasetService DatasetServiceDatasetReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetService"
    ADD CONSTRAINT "DatasetServiceDatasetReference" FOREIGN KEY ("Dataset") REFERENCES public."Dataset"("ID");


--
-- TOC entry 2338 (class 2606 OID 38156)
-- Name: DatasetService DatasetServiceServiceReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetService"
    ADD CONSTRAINT "DatasetServiceServiceReference" FOREIGN KEY ("Service") REFERENCES public."Service"("ID");


--
-- TOC entry 2351 (class 2606 OID 38428)
-- Name: Lock LockUserReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Lock"
    ADD CONSTRAINT "LockUserReference" FOREIGN KEY ("LockedBy") REFERENCES public."UserInfo"(id);


--
-- TOC entry 2352 (class 2606 OID 38441)
-- Name: Notification NotificationUserReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Notification"
    ADD CONSTRAINT "NotificationUserReference" FOREIGN KEY ("UserId") REFERENCES public."UserInfo"(id);


--
-- TOC entry 2343 (class 2606 OID 38161)
-- Name: UserDMP UserDMP_dmp_fkey; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."UserDMP"
    ADD CONSTRAINT "UserDMP_dmp_fkey" FOREIGN KEY (dmp) REFERENCES public."DMP"("ID");


--
-- TOC entry 2344 (class 2606 OID 38166)
-- Name: UserDMP UserDMP_usr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."UserDMP"
    ADD CONSTRAINT "UserDMP_usr_fkey" FOREIGN KEY (usr) REFERENCES public."UserInfo"(id);


--
-- TOC entry 2345 (class 2606 OID 38171)
-- Name: UserRole UserRole_userId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."UserRole"
    ADD CONSTRAINT "UserRole_userId_fkey" FOREIGN KEY ("UserId") REFERENCES public."UserInfo"(id);


--
-- TOC entry 2330 (class 2606 OID 38176)
-- Name: Dataset fk_dataset_creator; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Dataset"
    ADD CONSTRAINT fk_dataset_creator FOREIGN KEY ("Creator") REFERENCES public."UserInfo"(id);


--
-- TOC entry 2323 (class 2606 OID 38181)
-- Name: DMP fk_dmp_creator; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DMP"
    ADD CONSTRAINT fk_dmp_creator FOREIGN KEY ("Creator") REFERENCES public."UserInfo"(id);


--
-- TOC entry 2342 (class 2606 OID 38196)
-- Name: Grant fk_grant_content; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Grant"
    ADD CONSTRAINT fk_grant_content FOREIGN KEY ("Content") REFERENCES public."Content"("Id");


--
-- TOC entry 2341 (class 2606 OID 38201)
-- Name: Grant fk_grant_creator; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Grant"
    ADD CONSTRAINT fk_grant_creator FOREIGN KEY ("CreationUser") REFERENCES public."UserInfo"(id);


--
-- TOC entry 2339 (class 2606 OID 38186)
-- Name: Invitation fk_invitation_creator; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Invitation"
    ADD CONSTRAINT fk_invitation_creator FOREIGN KEY ("CreationUser") REFERENCES public."UserInfo"(id);


--
-- TOC entry 2340 (class 2606 OID 38191)
-- Name: Invitation fk_invitation_dmp; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Invitation"
    ADD CONSTRAINT fk_invitation_dmp FOREIGN KEY ("Dmp") REFERENCES public."DMP"("ID");


--
-- TOC entry 2349 (class 2606 OID 38378)
-- Name: Project fk_project_content; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Project"
    ADD CONSTRAINT fk_project_content FOREIGN KEY ("Content") REFERENCES public."Content"("Id");


--
-- TOC entry 2350 (class 2606 OID 38383)
-- Name: Project fk_project_creator; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Project"
    ADD CONSTRAINT fk_project_creator FOREIGN KEY ("CreationUser") REFERENCES public."UserInfo"(id);


--
-- TOC entry 2353 (class 2606 OID 46449)
-- Name: UserAssociation fk_userinfo_user_association_1; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."UserAssociation"
    ADD CONSTRAINT fk_userinfo_user_association_1 FOREIGN KEY ("firstUser") REFERENCES public."UserInfo"(id);


--
-- TOC entry 2354 (class 2606 OID 46454)
-- Name: UserAssociation fk_userinfo_user_association_2; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."UserAssociation"
    ADD CONSTRAINT fk_userinfo_user_association_2 FOREIGN KEY ("secondUser") REFERENCES public."UserInfo"(id);


--
-- TOC entry 2320 (class 2606 OID 38206)
-- Name: Credential fkey_credential_user; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."Credential"
    ADD CONSTRAINT fkey_credential_user FOREIGN KEY ("UserId") REFERENCES public."UserInfo"(id);


--
-- TOC entry 2333 (class 2606 OID 38211)
-- Name: DatasetExternalDataset fkey_datasetexternaldataset_dataset; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetExternalDataset"
    ADD CONSTRAINT fkey_datasetexternaldataset_dataset FOREIGN KEY ("Dataset") REFERENCES public."Dataset"("ID");


--
-- TOC entry 2334 (class 2606 OID 38216)
-- Name: DatasetExternalDataset fkey_datasetexternaldataset_externaldataset; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."DatasetExternalDataset"
    ADD CONSTRAINT fkey_datasetexternaldataset_externaldataset FOREIGN KEY ("ExternalDataset") REFERENCES public."ExternalDataset"("Id");


--
-- TOC entry 2346 (class 2606 OID 38221)
-- Name: UserToken fkey_usetoken_user; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--

ALTER TABLE ONLY public."UserToken"
    ADD CONSTRAINT fkey_usetoken_user FOREIGN KEY ("UserId") REFERENCES public."UserInfo"(id);


--
-- TOC entry 1827 (class 826 OID 16387)
-- Name: DEFAULT PRIVILEGES FOR TYPES; Type: DEFAULT ACL; Schema: -; Owner: :POSTGRES_USER
--

ALTER DEFAULT PRIVILEGES FOR ROLE :POSTGRES_USER REVOKE ALL ON TYPES  FROM :POSTGRES_USER;
ALTER DEFAULT PRIVILEGES FOR ROLE :POSTGRES_USER GRANT ALL ON TYPES  TO :POSTGRES_USER WITH GRANT OPTION;


--
-- TOC entry 1826 (class 826 OID 16386)
-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: -; Owner: :POSTGRES_USER
--

ALTER DEFAULT PRIVILEGES FOR ROLE :POSTGRES_USER REVOKE ALL ON FUNCTIONS  FROM :POSTGRES_USER;
ALTER DEFAULT PRIVILEGES FOR ROLE :POSTGRES_USER GRANT ALL ON FUNCTIONS  TO :POSTGRES_USER WITH GRANT OPTION;


-- Completed on 2020-05-12 17:07:43

--
-- PostgreSQL database dump complete
--

