--
-- PostgreSQL database dump
--

\restrict Og7SqV8a4r4ml7YK8Mvw1eC4sLxfOGHk6INJznYfU50IYGijCOAcaQboE8WuylC

-- Dumped from database version 16.11 (Ubuntu 16.11-0ubuntu0.24.04.1)
-- Dumped by pg_dump version 16.11 (Ubuntu 16.11-0ubuntu0.24.04.1)

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 xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: TenantStatus; Type: TYPE; Schema: public; Owner: painelsmtp
--

CREATE TYPE public."TenantStatus" AS ENUM (
    'ACTIVE',
    'SUSPENDED'
);


ALTER TYPE public."TenantStatus" OWNER TO painelsmtp;

--
-- Name: UserRole; Type: TYPE; Schema: public; Owner: painelsmtp
--

CREATE TYPE public."UserRole" AS ENUM (
    'ADMIN',
    'SUPPORT',
    'CLIENT_ADMIN',
    'CLIENT_VIEWER'
);


ALTER TYPE public."UserRole" OWNER TO painelsmtp;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: AlertEmailLog; Type: TABLE; Schema: public; Owner: painelsmtp
--

CREATE TABLE public."AlertEmailLog" (
    id text NOT NULL,
    "subaccountId" text NOT NULL,
    recipient text NOT NULL,
    status text NOT NULL,
    error text,
    "sentAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


ALTER TABLE public."AlertEmailLog" OWNER TO painelsmtp;

--
-- Name: Domain; Type: TABLE; Schema: public; Owner: painelsmtp
--

CREATE TABLE public."Domain" (
    id text NOT NULL,
    "tenantId" text NOT NULL,
    domain text NOT NULL,
    status text DEFAULT 'pending'::text NOT NULL,
    "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    "updatedAt" timestamp(3) without time zone NOT NULL
);


ALTER TABLE public."Domain" OWNER TO painelsmtp;

--
-- Name: Sender; Type: TABLE; Schema: public; Owner: painelsmtp
--

CREATE TABLE public."Sender" (
    id text NOT NULL,
    "tenantId" text NOT NULL,
    "emailFrom" text NOT NULL,
    name text,
    status text DEFAULT 'active'::text NOT NULL,
    "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    "updatedAt" timestamp(3) without time zone NOT NULL
);


ALTER TABLE public."Sender" OWNER TO painelsmtp;

--
-- Name: Smtp2goSubaccount; Type: TABLE; Schema: public; Owner: painelsmtp
--

CREATE TABLE public."Smtp2goSubaccount" (
    id text NOT NULL,
    "tenantId" text NOT NULL,
    "subaccountId" text NOT NULL,
    label text,
    "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    "updatedAt" timestamp(3) without time zone NOT NULL,
    "smtpUsername" text
);


ALTER TABLE public."Smtp2goSubaccount" OWNER TO painelsmtp;

--
-- Name: SubaccountMeta; Type: TABLE; Schema: public; Owner: painelsmtp
--

CREATE TABLE public."SubaccountMeta" (
    id text NOT NULL,
    "subaccountId" text NOT NULL,
    name text,
    cnpj text,
    "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    "updatedAt" timestamp(3) without time zone NOT NULL
);


ALTER TABLE public."SubaccountMeta" OWNER TO painelsmtp;

--
-- Name: SubaccountMetric; Type: TABLE; Schema: public; Owner: painelsmtp
--

CREATE TABLE public."SubaccountMetric" (
    id text NOT NULL,
    "subaccountId" text NOT NULL,
    name text,
    "bouncePercent" double precision,
    "spamPercent" double precision,
    emails integer,
    rejects integer,
    softbounces integer,
    hardbounces integer,
    "cycleStart" timestamp(3) without time zone,
    "cycleEnd" timestamp(3) without time zone,
    "cycleUsed" integer,
    "cycleRemaining" integer,
    "cycleMax" integer,
    "spamEmails" integer,
    "spamRejects" integer,
    unsubscribes integer,
    "fetchedAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


ALTER TABLE public."SubaccountMetric" OWNER TO painelsmtp;

--
-- Name: Tenant; Type: TABLE; Schema: public; Owner: painelsmtp
--

CREATE TABLE public."Tenant" (
    id text NOT NULL,
    name text NOT NULL,
    status public."TenantStatus" DEFAULT 'ACTIVE'::public."TenantStatus" NOT NULL,
    "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    "updatedAt" timestamp(3) without time zone NOT NULL
);


ALTER TABLE public."Tenant" OWNER TO painelsmtp;

--
-- Name: User; Type: TABLE; Schema: public; Owner: painelsmtp
--

CREATE TABLE public."User" (
    id text NOT NULL,
    email text NOT NULL,
    name text NOT NULL,
    password text NOT NULL,
    role public."UserRole" DEFAULT 'CLIENT_VIEWER'::public."UserRole" NOT NULL,
    "tenantId" text,
    "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    "updatedAt" timestamp(3) without time zone NOT NULL,
    cnpj text
);


ALTER TABLE public."User" OWNER TO painelsmtp;

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

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
);


ALTER TABLE public._prisma_migrations OWNER TO painelsmtp;

--
-- Name: AlertEmailLog AlertEmailLog_pkey; Type: CONSTRAINT; Schema: public; Owner: painelsmtp
--

ALTER TABLE ONLY public."AlertEmailLog"
    ADD CONSTRAINT "AlertEmailLog_pkey" PRIMARY KEY (id);


--
-- Name: Domain Domain_pkey; Type: CONSTRAINT; Schema: public; Owner: painelsmtp
--

ALTER TABLE ONLY public."Domain"
    ADD CONSTRAINT "Domain_pkey" PRIMARY KEY (id);


--
-- Name: Sender Sender_pkey; Type: CONSTRAINT; Schema: public; Owner: painelsmtp
--

ALTER TABLE ONLY public."Sender"
    ADD CONSTRAINT "Sender_pkey" PRIMARY KEY (id);


--
-- Name: Smtp2goSubaccount Smtp2goSubaccount_pkey; Type: CONSTRAINT; Schema: public; Owner: painelsmtp
--

ALTER TABLE ONLY public."Smtp2goSubaccount"
    ADD CONSTRAINT "Smtp2goSubaccount_pkey" PRIMARY KEY (id);


--
-- Name: SubaccountMeta SubaccountMeta_pkey; Type: CONSTRAINT; Schema: public; Owner: painelsmtp
--

ALTER TABLE ONLY public."SubaccountMeta"
    ADD CONSTRAINT "SubaccountMeta_pkey" PRIMARY KEY (id);


--
-- Name: SubaccountMetric SubaccountMetric_pkey; Type: CONSTRAINT; Schema: public; Owner: painelsmtp
--

ALTER TABLE ONLY public."SubaccountMetric"
    ADD CONSTRAINT "SubaccountMetric_pkey" PRIMARY KEY (id);


--
-- Name: Tenant Tenant_pkey; Type: CONSTRAINT; Schema: public; Owner: painelsmtp
--

ALTER TABLE ONLY public."Tenant"
    ADD CONSTRAINT "Tenant_pkey" PRIMARY KEY (id);


--
-- Name: User User_pkey; Type: CONSTRAINT; Schema: public; Owner: painelsmtp
--

ALTER TABLE ONLY public."User"
    ADD CONSTRAINT "User_pkey" PRIMARY KEY (id);


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

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


--
-- Name: AlertEmailLog_sentAt_idx; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE INDEX "AlertEmailLog_sentAt_idx" ON public."AlertEmailLog" USING btree ("sentAt");


--
-- Name: AlertEmailLog_subaccountId_idx; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE INDEX "AlertEmailLog_subaccountId_idx" ON public."AlertEmailLog" USING btree ("subaccountId");


--
-- Name: Domain_tenantId_domain_key; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE UNIQUE INDEX "Domain_tenantId_domain_key" ON public."Domain" USING btree ("tenantId", domain);


--
-- Name: Domain_tenantId_idx; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE INDEX "Domain_tenantId_idx" ON public."Domain" USING btree ("tenantId");


--
-- Name: Sender_tenantId_emailFrom_key; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE UNIQUE INDEX "Sender_tenantId_emailFrom_key" ON public."Sender" USING btree ("tenantId", "emailFrom");


--
-- Name: Sender_tenantId_idx; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE INDEX "Sender_tenantId_idx" ON public."Sender" USING btree ("tenantId");


--
-- Name: Smtp2goSubaccount_subaccountId_key; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE UNIQUE INDEX "Smtp2goSubaccount_subaccountId_key" ON public."Smtp2goSubaccount" USING btree ("subaccountId");


--
-- Name: Smtp2goSubaccount_tenantId_key; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE UNIQUE INDEX "Smtp2goSubaccount_tenantId_key" ON public."Smtp2goSubaccount" USING btree ("tenantId");


--
-- Name: SubaccountMeta_subaccountId_key; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE UNIQUE INDEX "SubaccountMeta_subaccountId_key" ON public."SubaccountMeta" USING btree ("subaccountId");


--
-- Name: SubaccountMetric_fetchedAt_idx; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE INDEX "SubaccountMetric_fetchedAt_idx" ON public."SubaccountMetric" USING btree ("fetchedAt");


--
-- Name: SubaccountMetric_subaccountId_cycleStart_cycleEnd_key; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE UNIQUE INDEX "SubaccountMetric_subaccountId_cycleStart_cycleEnd_key" ON public."SubaccountMetric" USING btree ("subaccountId", "cycleStart", "cycleEnd");


--
-- Name: SubaccountMetric_subaccountId_idx; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE INDEX "SubaccountMetric_subaccountId_idx" ON public."SubaccountMetric" USING btree ("subaccountId");


--
-- Name: User_cnpj_idx; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE INDEX "User_cnpj_idx" ON public."User" USING btree (cnpj);


--
-- Name: User_email_key; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE UNIQUE INDEX "User_email_key" ON public."User" USING btree (email);


--
-- Name: User_role_idx; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE INDEX "User_role_idx" ON public."User" USING btree (role);


--
-- Name: User_tenantId_idx; Type: INDEX; Schema: public; Owner: painelsmtp
--

CREATE INDEX "User_tenantId_idx" ON public."User" USING btree ("tenantId");


--
-- Name: Domain Domain_tenantId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: painelsmtp
--

ALTER TABLE ONLY public."Domain"
    ADD CONSTRAINT "Domain_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES public."Tenant"(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: Sender Sender_tenantId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: painelsmtp
--

ALTER TABLE ONLY public."Sender"
    ADD CONSTRAINT "Sender_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES public."Tenant"(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: Smtp2goSubaccount Smtp2goSubaccount_tenantId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: painelsmtp
--

ALTER TABLE ONLY public."Smtp2goSubaccount"
    ADD CONSTRAINT "Smtp2goSubaccount_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES public."Tenant"(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: User User_tenantId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: painelsmtp
--

ALTER TABLE ONLY public."User"
    ADD CONSTRAINT "User_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES public."Tenant"(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--

\unrestrict Og7SqV8a4r4ml7YK8Mvw1eC4sLxfOGHk6INJznYfU50IYGijCOAcaQboE8WuylC

