--
-- PostgreSQL database dump
--

\restrict kmfsZ1NUIbedynsFb23ZupLqit5AgAIEj3QsIeG1L5YkBtJbYtar24uoNvU1ZrF

-- Dumped from database version 18.1
-- Dumped by pg_dump version 18.1

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;

SET default_tablespace = '';

SET default_table_access_method = heap;

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

CREATE TABLE public.admission (
    id integer NOT NULL,
    regex text NOT NULL,
    "createdAt" timestamp with time zone DEFAULT now(),
    "createdById" integer NOT NULL,
    "modifiedAt" timestamp with time zone,
    "modifiedById" integer
);


--
-- Name: admissions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.admissions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: admissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.admissions_id_seq OWNED BY public.admission.id;


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

CREATE TABLE public.admissions_roles (
    "admissionId" integer NOT NULL,
    "roleId" integer NOT NULL
);


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

CREATE TABLE public."emailToken" (
    id integer NOT NULL,
    "userId" integer NOT NULL,
    email text NOT NULL,
    token text NOT NULL,
    "createdAt" timestamp with time zone DEFAULT now() NOT NULL,
    "cancelledAt" timestamp with time zone,
    "consumedAt" timestamp with time zone
);


--
-- Name: emailToken_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public."emailToken_id_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: emailToken_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public."emailToken_id_seq" OWNED BY public."emailToken".id;


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

CREATE TABLE public.invite (
    id integer NOT NULL,
    email text NOT NULL,
    token text NOT NULL,
    "createdAt" timestamp with time zone DEFAULT now() NOT NULL,
    "createdById" integer,
    "modifiedAt" timestamp with time zone,
    "modifiedById" integer,
    "consumedAt" timestamp with time zone,
    "consumedById" integer
);


--
-- Name: invite_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.invite_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: invite_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.invite_id_seq OWNED BY public.invite.id;


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

CREATE TABLE public.invites_roles (
    "inviteId" integer NOT NULL,
    "roleId" integer NOT NULL
);


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

CREATE TABLE public."passwordToken" (
    id integer NOT NULL,
    "userId" integer NOT NULL,
    token text NOT NULL,
    "createdAt" timestamp with time zone DEFAULT now() NOT NULL,
    "cancelledAt" timestamp with time zone,
    "consumedAt" timestamp with time zone
);


--
-- Name: passwordToken_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public."passwordToken_id_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: passwordToken_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public."passwordToken_id_seq" OWNED BY public."passwordToken".id;


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

CREATE TABLE public.role (
    id integer NOT NULL,
    name character varying(64) NOT NULL,
    "createdAt" timestamp with time zone DEFAULT now() NOT NULL,
    "createdById" integer,
    "modifiedAt" timestamp with time zone,
    "modifiedById" integer
);


--
-- Name: role_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.role_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.role_id_seq OWNED BY public.role.id;


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

CREATE TABLE public."user" (
    id integer NOT NULL,
    email character varying(254) NOT NULL,
    password character varying(256) NOT NULL,
    "lastLoginAt" timestamp with time zone,
    "loginAttempts" integer DEFAULT 0,
    "lastLoginAttemptAt" timestamp with time zone,
    "lastActivityAt" timestamp with time zone,
    "emailVerifiedAt" timestamp with time zone,
    "bannedAt" timestamp with time zone,
    "bannedById" integer,
    "blockedAt" timestamp with time zone,
    "blockedById" integer,
    "createdAt" timestamp with time zone DEFAULT now() NOT NULL
);


--
-- Name: user_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.user_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.user_id_seq OWNED BY public."user".id;


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

CREATE TABLE public.users_roles (
    "userId" integer NOT NULL,
    "roleId" integer NOT NULL
);


--
-- Name: admission id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admission ALTER COLUMN id SET DEFAULT nextval('public.admissions_id_seq'::regclass);


--
-- Name: emailToken id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."emailToken" ALTER COLUMN id SET DEFAULT nextval('public."emailToken_id_seq"'::regclass);


--
-- Name: invite id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invite ALTER COLUMN id SET DEFAULT nextval('public.invite_id_seq'::regclass);


--
-- Name: passwordToken id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."passwordToken" ALTER COLUMN id SET DEFAULT nextval('public."passwordToken_id_seq"'::regclass);


--
-- Name: role id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.role ALTER COLUMN id SET DEFAULT nextval('public.role_id_seq'::regclass);


--
-- Name: user id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user" ALTER COLUMN id SET DEFAULT nextval('public.user_id_seq'::regclass);


--
-- Name: admission admission_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admission
    ADD CONSTRAINT admission_pkey PRIMARY KEY (id);


--
-- Name: admission admission_regex_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admission
    ADD CONSTRAINT admission_regex_key UNIQUE (regex);


--
-- Name: admissions_roles admissions_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admissions_roles
    ADD CONSTRAINT admissions_roles_pkey PRIMARY KEY ("admissionId", "roleId");


--
-- Name: emailToken email_token_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."emailToken"
    ADD CONSTRAINT email_token_pkey PRIMARY KEY (id);


--
-- Name: emailToken email_token_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."emailToken"
    ADD CONSTRAINT email_token_unique UNIQUE ("userId", email);


--
-- Name: invite invite_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invite
    ADD CONSTRAINT invite_pkey PRIMARY KEY (id);


--
-- Name: invites_roles invites_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invites_roles
    ADD CONSTRAINT invites_roles_pkey PRIMARY KEY ("inviteId", "roleId");


--
-- Name: passwordToken passwordToken_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."passwordToken"
    ADD CONSTRAINT "passwordToken_pkey" PRIMARY KEY (id);


--
-- Name: role role_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.role
    ADD CONSTRAINT role_name_key UNIQUE (name);


--
-- Name: role role_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.role
    ADD CONSTRAINT role_pkey PRIMARY KEY (id);


--
-- Name: user user_email_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user"
    ADD CONSTRAINT user_email_key UNIQUE (email);


--
-- Name: user user_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user"
    ADD CONSTRAINT user_pkey PRIMARY KEY (id);


--
-- Name: users_roles users_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users_roles
    ADD CONSTRAINT users_roles_pkey PRIMARY KEY ("userId", "roleId");


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

CREATE INDEX "fki_admission_createdById_fkey" ON public.admission USING btree ("createdById");


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

CREATE INDEX "fki_admission_modifiedById_fkey" ON public.admission USING btree ("modifiedById");


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

CREATE INDEX "fki_invite_modifiedById_fkey" ON public.invite USING btree ("modifiedById");


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

CREATE INDEX "fki_role_createdById_fkey" ON public.role USING btree ("createdById");


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

CREATE INDEX "fki_role_modifiedById_fkey" ON public.role USING btree ("modifiedById");


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

CREATE INDEX "fki_user_bannedById_fkey" ON public."user" USING btree ("bannedById");


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

CREATE INDEX "fki_user_blockedById_fkey" ON public."user" USING btree ("blockedById");


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

CREATE INDEX "fki_users_roles_roleId_fkey" ON public.users_roles USING btree ("roleId");


--
-- Name: admission admission_createdById_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admission
    ADD CONSTRAINT "admission_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES public."user"(id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: admission admission_modifiedById_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admission
    ADD CONSTRAINT "admission_modifiedById_fkey" FOREIGN KEY ("modifiedById") REFERENCES public."user"(id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: admissions_roles admissions_roles_admissionId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admissions_roles
    ADD CONSTRAINT "admissions_roles_admissionId_fkey" FOREIGN KEY ("admissionId") REFERENCES public.admission(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: admissions_roles admissions_roles_roleId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admissions_roles
    ADD CONSTRAINT "admissions_roles_roleId_fkey" FOREIGN KEY ("roleId") REFERENCES public.role(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: emailToken emailToken_userId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."emailToken"
    ADD CONSTRAINT "emailToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES public."user"(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: invite invite_consumedById_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invite
    ADD CONSTRAINT "invite_consumedById_fkey" FOREIGN KEY ("consumedById") REFERENCES public."user"(id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: invite invite_createdById_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invite
    ADD CONSTRAINT "invite_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES public."user"(id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: invite invite_modifiedById_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invite
    ADD CONSTRAINT "invite_modifiedById_fkey" FOREIGN KEY ("modifiedById") REFERENCES public."user"(id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: invites_roles invites_roles_inviteId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invites_roles
    ADD CONSTRAINT "invites_roles_inviteId_fkey" FOREIGN KEY ("inviteId") REFERENCES public.invite(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: invites_roles invites_roles_roleId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invites_roles
    ADD CONSTRAINT "invites_roles_roleId_fkey" FOREIGN KEY ("roleId") REFERENCES public.role(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: passwordToken passwordToken_userId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."passwordToken"
    ADD CONSTRAINT "passwordToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES public."user"(id);


--
-- Name: role role_createdById_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.role
    ADD CONSTRAINT "role_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES public."user"(id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: role role_modifiedById_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.role
    ADD CONSTRAINT "role_modifiedById_fkey" FOREIGN KEY ("modifiedById") REFERENCES public."user"(id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: user user_bannedById_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user"
    ADD CONSTRAINT "user_bannedById_fkey" FOREIGN KEY ("bannedById") REFERENCES public."user"(id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: user user_blockedById_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user"
    ADD CONSTRAINT "user_blockedById_fkey" FOREIGN KEY ("blockedById") REFERENCES public."user"(id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: users_roles users_roles_roleId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users_roles
    ADD CONSTRAINT "users_roles_roleId_fkey" FOREIGN KEY ("roleId") REFERENCES public.role(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: users_roles users_roles_userId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users_roles
    ADD CONSTRAINT "users_roles_userId_fkey" FOREIGN KEY ("userId") REFERENCES public."user"(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--

\unrestrict kmfsZ1NUIbedynsFb23ZupLqit5AgAIEj3QsIeG1L5YkBtJbYtar24uoNvU1ZrF

