-- Table: public.users

-- DROP TABLE IF EXISTS public.users;

CREATE TABLE IF NOT EXISTS public.users
(
    "UserID" character varying(10) COLLATE pg_catalog."default" NOT NULL,
    "ActiveDirectoryAuth" boolean NOT NULL DEFAULT false,
    "Name" character varying(250) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    "Surname" character varying(250) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    "Email" character varying(500) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    "Password" character varying(255) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    "CreationDate" timestamp without time zone NOT NULL DEFAULT now(),
    "LastChanged" timestamp without time zone NOT NULL DEFAULT now(),
    "PrivateKey" text COLLATE pg_catalog."default",
    "DepartmentID" integer NOT NULL,
    "Status" smallint NOT NULL DEFAULT 1,
    CONSTRAINT users_pkey PRIMARY KEY ("UserID"),
    CONSTRAINT "DepartmentID" FOREIGN KEY ("DepartmentID")
        REFERENCES public.departments ("DepartmentID") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        NOT VALID
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.users
    OWNER to postgres;

COMMENT ON TABLE public.users
    IS 'Table containing user information';

COMMENT ON COLUMN public.users."PrivateKey"
    IS 'Private Key of the user with which the user can sign things';