--
-- PostgreSQL database dump
--

\restrict V6pdk4hxHk7VQYnrn2NO7clngbg01PyshHFsoDbbbQ28wtOAfkiTfl6BQQ0BtLG

-- Dumped from database version 16.10 (Ubuntu 16.10-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: EvCharging; Type: TYPE; Schema: public; Owner: lomavuokraus
--

CREATE TYPE public."EvCharging" AS ENUM (
    'NONE',
    'FREE',
    'PAID'
);


ALTER TYPE public."EvCharging" OWNER TO lomavuokraus;

--
-- Name: ListingStatus; Type: TYPE; Schema: public; Owner: lomavuokraus
--

CREATE TYPE public."ListingStatus" AS ENUM (
    'DRAFT',
    'PENDING',
    'PUBLISHED',
    'REJECTED',
    'REMOVED'
);


ALTER TYPE public."ListingStatus" OWNER TO lomavuokraus;

--
-- Name: Role; Type: TYPE; Schema: public; Owner: lomavuokraus
--

CREATE TYPE public."Role" AS ENUM (
    'USER',
    'ADMIN',
    'USER_MODERATOR',
    'LISTING_MODERATOR'
);


ALTER TYPE public."Role" OWNER TO lomavuokraus;

--
-- Name: UserStatus; Type: TYPE; Schema: public; Owner: lomavuokraus
--

CREATE TYPE public."UserStatus" AS ENUM (
    'PENDING',
    'ACTIVE',
    'DISABLED',
    'REJECTED',
    'REMOVED'
);


ALTER TYPE public."UserStatus" OWNER TO lomavuokraus;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: Listing; Type: TABLE; Schema: public; Owner: lomavuokraus
--

CREATE TABLE public."Listing" (
    id text NOT NULL,
    "ownerId" text NOT NULL,
    country text NOT NULL,
    region text NOT NULL,
    city text NOT NULL,
    "addressNote" text,
    latitude double precision,
    longitude double precision,
    "maxGuests" integer NOT NULL,
    bedrooms integer NOT NULL,
    beds integer NOT NULL,
    bathrooms integer NOT NULL,
    "hasSauna" boolean DEFAULT false NOT NULL,
    "hasFireplace" boolean DEFAULT false NOT NULL,
    "hasWifi" boolean DEFAULT false NOT NULL,
    "petsAllowed" boolean DEFAULT false NOT NULL,
    "byTheLake" boolean DEFAULT false NOT NULL,
    "contactName" text NOT NULL,
    "contactEmail" text NOT NULL,
    "contactPhone" text,
    "externalUrl" text,
    published boolean DEFAULT true NOT NULL,
    "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    "updatedAt" timestamp(3) without time zone NOT NULL,
    "approvedAt" timestamp(3) without time zone,
    "approvedById" text,
    status public."ListingStatus" DEFAULT 'PENDING'::public."ListingStatus" NOT NULL,
    "rejectedAt" timestamp(3) without time zone,
    "rejectedById" text,
    "rejectedReason" text,
    "removedAt" timestamp(3) without time zone,
    "removedById" text,
    "removedReason" text,
    "hasAirConditioning" boolean DEFAULT false NOT NULL,
    "streetAddress" text,
    "evCharging" public."EvCharging" DEFAULT 'NONE'::public."EvCharging" NOT NULL,
    "isSample" boolean DEFAULT false NOT NULL,
    "hasKitchen" boolean DEFAULT false NOT NULL,
    "hasDishwasher" boolean DEFAULT false NOT NULL,
    "hasWashingMachine" boolean DEFAULT false NOT NULL,
    "hasBarbecue" boolean DEFAULT false NOT NULL,
    "calendarUrls" text[] DEFAULT ARRAY[]::text[] NOT NULL,
    "priceWeekdayEuros" integer,
    "priceWeekendEuros" integer,
    "hasMicrowave" boolean DEFAULT false NOT NULL,
    "hasFreeParking" boolean DEFAULT false NOT NULL
);


ALTER TABLE public."Listing" OWNER TO lomavuokraus;

--
-- Name: ListingImage; Type: TABLE; Schema: public; Owner: lomavuokraus
--

CREATE TABLE public."ListingImage" (
    id text NOT NULL,
    "listingId" text NOT NULL,
    url text,
    "altText" text,
    "order" integer DEFAULT 0 NOT NULL,
    "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    "updatedAt" timestamp(3) without time zone NOT NULL,
    "isCover" boolean DEFAULT false NOT NULL,
    data bytea,
    "mimeType" text,
    size integer
);


ALTER TABLE public."ListingImage" OWNER TO lomavuokraus;

--
-- Name: ListingTranslation; Type: TABLE; Schema: public; Owner: lomavuokraus
--

CREATE TABLE public."ListingTranslation" (
    id text NOT NULL,
    "listingId" text NOT NULL,
    locale text NOT NULL,
    title text NOT NULL,
    slug text NOT NULL,
    description text NOT NULL,
    teaser text,
    "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    "updatedAt" timestamp(3) without time zone NOT NULL
);


ALTER TABLE public."ListingTranslation" OWNER TO lomavuokraus;

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

CREATE TABLE public."User" (
    id text NOT NULL,
    email text NOT NULL,
    name text,
    role public."Role" DEFAULT 'USER'::public."Role" NOT NULL,
    "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    "updatedAt" timestamp(3) without time zone NOT NULL,
    "approvedAt" timestamp(3) without time zone,
    "emailVerifiedAt" timestamp(3) without time zone,
    "passwordHash" text DEFAULT ''::text NOT NULL,
    status public."UserStatus" DEFAULT 'PENDING'::public."UserStatus" NOT NULL,
    "rejectedAt" timestamp(3) without time zone,
    "rejectedReason" text,
    "removedAt" timestamp(3) without time zone,
    "removedById" text,
    "removedReason" text,
    phone text
);


ALTER TABLE public."User" OWNER TO lomavuokraus;

--
-- Name: VerificationToken; Type: TABLE; Schema: public; Owner: lomavuokraus
--

CREATE TABLE public."VerificationToken" (
    id text NOT NULL,
    "userId" text NOT NULL,
    token text NOT NULL,
    type text NOT NULL,
    "expiresAt" timestamp(3) without time zone NOT NULL,
    "consumedAt" timestamp(3) without time zone,
    "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


ALTER TABLE public."VerificationToken" OWNER TO lomavuokraus;

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

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

--
-- Name: ListingImage ListingImage_pkey; Type: CONSTRAINT; Schema: public; Owner: lomavuokraus
--

ALTER TABLE ONLY public."ListingImage"
    ADD CONSTRAINT "ListingImage_pkey" PRIMARY KEY (id);


--
-- Name: ListingTranslation ListingTranslation_pkey; Type: CONSTRAINT; Schema: public; Owner: lomavuokraus
--

ALTER TABLE ONLY public."ListingTranslation"
    ADD CONSTRAINT "ListingTranslation_pkey" PRIMARY KEY (id);


--
-- Name: Listing Listing_pkey; Type: CONSTRAINT; Schema: public; Owner: lomavuokraus
--

ALTER TABLE ONLY public."Listing"
    ADD CONSTRAINT "Listing_pkey" PRIMARY KEY (id);


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

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


--
-- Name: VerificationToken VerificationToken_pkey; Type: CONSTRAINT; Schema: public; Owner: lomavuokraus
--

ALTER TABLE ONLY public."VerificationToken"
    ADD CONSTRAINT "VerificationToken_pkey" PRIMARY KEY (id);


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

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


--
-- Name: ListingTranslation_listingId_locale_key; Type: INDEX; Schema: public; Owner: lomavuokraus
--

CREATE UNIQUE INDEX "ListingTranslation_listingId_locale_key" ON public."ListingTranslation" USING btree ("listingId", locale);


--
-- Name: ListingTranslation_slug_locale_key; Type: INDEX; Schema: public; Owner: lomavuokraus
--

CREATE UNIQUE INDEX "ListingTranslation_slug_locale_key" ON public."ListingTranslation" USING btree (slug, locale);


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

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


--
-- Name: VerificationToken_token_key; Type: INDEX; Schema: public; Owner: lomavuokraus
--

CREATE UNIQUE INDEX "VerificationToken_token_key" ON public."VerificationToken" USING btree (token);


--
-- Name: VerificationToken_userId_idx; Type: INDEX; Schema: public; Owner: lomavuokraus
--

CREATE INDEX "VerificationToken_userId_idx" ON public."VerificationToken" USING btree ("userId");


--
-- Name: ListingImage ListingImage_listingId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: lomavuokraus
--

ALTER TABLE ONLY public."ListingImage"
    ADD CONSTRAINT "ListingImage_listingId_fkey" FOREIGN KEY ("listingId") REFERENCES public."Listing"(id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: ListingTranslation ListingTranslation_listingId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: lomavuokraus
--

ALTER TABLE ONLY public."ListingTranslation"
    ADD CONSTRAINT "ListingTranslation_listingId_fkey" FOREIGN KEY ("listingId") REFERENCES public."Listing"(id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: Listing Listing_approvedById_fkey; Type: FK CONSTRAINT; Schema: public; Owner: lomavuokraus
--

ALTER TABLE ONLY public."Listing"
    ADD CONSTRAINT "Listing_approvedById_fkey" FOREIGN KEY ("approvedById") REFERENCES public."User"(id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: Listing Listing_ownerId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: lomavuokraus
--

ALTER TABLE ONLY public."Listing"
    ADD CONSTRAINT "Listing_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES public."User"(id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: VerificationToken VerificationToken_userId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: lomavuokraus
--

ALTER TABLE ONLY public."VerificationToken"
    ADD CONSTRAINT "VerificationToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES public."User"(id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- PostgreSQL database dump complete
--

\unrestrict V6pdk4hxHk7VQYnrn2NO7clngbg01PyshHFsoDbbbQ28wtOAfkiTfl6BQQ0BtLG

