--
-- PostgreSQL database dump
--


-- Dumped from database version 16.10 (Debian 16.10-1.pgdg13+1)
-- Dumped by pg_dump version 16.10 (Ubuntu 16.10-1.pgdg22.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;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: alembic_version; Type: TABLE; Schema: public; Owner: postgres
--

--
-- Name: authors; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.authors (
    id integer NOT NULL,
    ghost_id character varying(64) NOT NULL,
    slug character varying(191) NOT NULL,
    name character varying(255) NOT NULL,
    profile_image text,
    cover_image text,
    bio text,
    website text,
    location text,
    facebook text,
    twitter text,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    deleted_at timestamp with time zone
);


ALTER TABLE public.authors OWNER TO postgres;

--
-- Name: authors_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.authors_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.authors_id_seq OWNER TO postgres;

--
-- Name: authors_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.authors_id_seq OWNED BY public.authors.id;


--
-- Name: calendar_entries; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.calendar_entries (
    id integer NOT NULL,
    calendar_id integer NOT NULL,
    name character varying(255) NOT NULL,
    start_at timestamp with time zone NOT NULL,
    end_at timestamp with time zone,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone,
    CONSTRAINT ck_calendar_entries_end_after_start CHECK (((end_at IS NULL) OR (end_at >= start_at)))
);


ALTER TABLE public.calendar_entries OWNER TO postgres;

--
-- Name: calendar_entries_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.calendar_entries_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.calendar_entries_id_seq OWNER TO postgres;

--
-- Name: calendar_entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.calendar_entries_id_seq OWNED BY public.calendar_entries.id;


--
-- Name: calendar_slots; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.calendar_slots (
    id integer NOT NULL,
    calendar_id integer NOT NULL,
    name character varying(255) NOT NULL,
    description text,
    mon boolean DEFAULT false NOT NULL,
    tue boolean DEFAULT false NOT NULL,
    wed boolean DEFAULT false NOT NULL,
    thu boolean DEFAULT false NOT NULL,
    fri boolean DEFAULT false NOT NULL,
    sat boolean DEFAULT false NOT NULL,
    sun boolean DEFAULT false NOT NULL,
    time_start time without time zone NOT NULL,
    time_end time without time zone NOT NULL,
    cost numeric(10,2),
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone,
    CONSTRAINT ck_calendar_slots_time_end_after_start CHECK ((time_end > time_start))
);


ALTER TABLE public.calendar_slots OWNER TO postgres;

--
-- Name: calendar_slots_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.calendar_slots_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.calendar_slots_id_seq OWNER TO postgres;

--
-- Name: calendar_slots_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.calendar_slots_id_seq OWNED BY public.calendar_slots.id;


--
-- Name: calendars; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.calendars (
    id integer NOT NULL,
    post_id integer NOT NULL,
    name character varying(255) NOT NULL,
    slug character varying(255) NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone,
    description text
);


ALTER TABLE public.calendars OWNER TO postgres;

--
-- Name: calendars_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.calendars_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.calendars_id_seq OWNER TO postgres;

--
-- Name: calendars_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.calendars_id_seq OWNED BY public.calendars.id;


--
-- Name: ghost_labels; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.ghost_labels (
    id integer NOT NULL,
    ghost_id character varying(64) NOT NULL,
    name character varying(255) NOT NULL,
    slug character varying(255),
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.ghost_labels OWNER TO postgres;

--
-- Name: ghost_labels_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.ghost_labels_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.ghost_labels_id_seq OWNER TO postgres;

--
-- Name: ghost_labels_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.ghost_labels_id_seq OWNED BY public.ghost_labels.id;


--
-- Name: ghost_newsletters; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.ghost_newsletters (
    id integer NOT NULL,
    ghost_id character varying(64) NOT NULL,
    name character varying(255) NOT NULL,
    slug character varying(255),
    description text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.ghost_newsletters OWNER TO postgres;

--
-- Name: ghost_newsletters_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.ghost_newsletters_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.ghost_newsletters_id_seq OWNER TO postgres;

--
-- Name: ghost_newsletters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.ghost_newsletters_id_seq OWNED BY public.ghost_newsletters.id;


--
-- Name: ghost_subscriptions; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.ghost_subscriptions (
    id integer NOT NULL,
    ghost_id character varying(64) NOT NULL,
    user_id integer NOT NULL,
    status character varying(50),
    tier_id integer,
    cadence character varying(50),
    price_amount integer,
    price_currency character varying(10),
    stripe_customer_id character varying(255),
    stripe_subscription_id character varying(255),
    raw jsonb
);


ALTER TABLE public.ghost_subscriptions OWNER TO postgres;

--
-- Name: ghost_subscriptions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.ghost_subscriptions_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.ghost_subscriptions_id_seq OWNER TO postgres;

--
-- Name: ghost_subscriptions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.ghost_subscriptions_id_seq OWNED BY public.ghost_subscriptions.id;


--
-- Name: ghost_tiers; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.ghost_tiers (
    id integer NOT NULL,
    ghost_id character varying(64) NOT NULL,
    name character varying(255) NOT NULL,
    slug character varying(255),
    type character varying(50),
    visibility character varying(50)
);


ALTER TABLE public.ghost_tiers OWNER TO postgres;

--
-- Name: ghost_tiers_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.ghost_tiers_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.ghost_tiers_id_seq OWNER TO postgres;

--
-- Name: ghost_tiers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.ghost_tiers_id_seq OWNED BY public.ghost_tiers.id;


--
-- Name: kv; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.kv (
    key character varying(120) NOT NULL,
    value text,
    updated_at timestamp with time zone NOT NULL
);


ALTER TABLE public.kv OWNER TO postgres;

--
-- Name: link_errors; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.link_errors (
    id integer NOT NULL,
    product_slug character varying(255),
    href text,
    text text,
    top character varying(255),
    sub character varying(255),
    target_slug character varying(255),
    type character varying(255),
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE public.link_errors OWNER TO postgres;

--
-- Name: link_errors_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.link_errors_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.link_errors_id_seq OWNER TO postgres;

--
-- Name: link_errors_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.link_errors_id_seq OWNED BY public.link_errors.id;


--
-- Name: link_externals; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.link_externals (
    id integer NOT NULL,
    product_slug character varying(255),
    href text,
    text text,
    host character varying(255),
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone

);


ALTER TABLE public.link_externals OWNER TO postgres;

--
-- Name: link_externals_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.link_externals_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.link_externals_id_seq OWNER TO postgres;

--
-- Name: link_externals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.link_externals_id_seq OWNED BY public.link_externals.id;


--
-- Name: listing_items; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.listing_items (
    id integer NOT NULL,
    listing_id integer NOT NULL,
    slug character varying(255) NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE public.listing_items OWNER TO postgres;

--
-- Name: listing_items_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.listing_items_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.listing_items_id_seq OWNER TO postgres;

--
-- Name: listing_items_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.listing_items_id_seq OWNED BY public.listing_items.id;


--
-- Name: listings; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.listings (
    id integer NOT NULL,
    total_pages integer,
    top_id integer NOT NULL,
    sub_id integer,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE public.listings OWNER TO postgres;

--
-- Name: listings_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.listings_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.listings_id_seq OWNER TO postgres;

--
-- Name: listings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.listings_id_seq OWNED BY public.listings.id;


--
-- Name: magic_links; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.magic_links (
    id integer NOT NULL,
    token character varying(128) NOT NULL,
    user_id integer NOT NULL,
    purpose character varying(32) NOT NULL,
    expires_at timestamp with time zone NOT NULL,
    used_at timestamp with time zone,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    ip character varying(64),
    user_agent character varying(256)
);


ALTER TABLE public.magic_links OWNER TO postgres;

--
-- Name: magic_links_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.magic_links_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.magic_links_id_seq OWNER TO postgres;

--
-- Name: magic_links_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.magic_links_id_seq OWNED BY public.magic_links.id;


--
-- Name: nav_subs; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.nav_subs (
    id integer NOT NULL,
    top_id integer NOT NULL,
    label character varying(255),
    slug character varying(255) NOT NULL,
    href text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE public.nav_subs OWNER TO postgres;

--
-- Name: nav_subs_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.nav_subs_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.nav_subs_id_seq OWNER TO postgres;

--
-- Name: nav_subs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.nav_subs_id_seq OWNED BY public.nav_subs.id;


--
-- Name: nav_tops; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.nav_tops (
    id integer NOT NULL,
    label character varying(255) NOT NULL,
    slug character varying(255) NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE public.nav_tops OWNER TO postgres;

--
-- Name: nav_tops_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.nav_tops_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.nav_tops_id_seq OWNER TO postgres;

--
-- Name: nav_tops_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.nav_tops_id_seq OWNED BY public.nav_tops.id;


--
-- Name: post_authors; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.post_authors (
    post_id integer NOT NULL,
    author_id integer NOT NULL,
    sort_order integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.post_authors OWNER TO postgres;

--
-- Name: post_tags; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.post_tags (
    post_id integer NOT NULL,
    tag_id integer NOT NULL,
    sort_order integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.post_tags OWNER TO postgres;

--
-- Name: posts; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.posts (
    id integer NOT NULL,
    ghost_id character varying(64) NOT NULL,
    uuid character varying(64) NOT NULL,
    slug character varying(191) NOT NULL,
    title character varying(500) NOT NULL,
    html text,
    plaintext text,
    mobiledoc text,
    lexical text,
    feature_image text,
    feature_image_alt text,
    feature_image_caption text,
    excerpt text,
    custom_excerpt text,
    visibility character varying(32) DEFAULT 'public'::character varying NOT NULL,
    status character varying(32) DEFAULT 'draft'::character varying NOT NULL,
    featured boolean DEFAULT false NOT NULL,
    is_page boolean DEFAULT false NOT NULL,
    email_only boolean DEFAULT false NOT NULL,
    canonical_url text,
    meta_title character varying(500),
    meta_description text,
    og_image text,
    og_title character varying(500),
    og_description text,
    twitter_image text,
    twitter_title character varying(500),
    twitter_description text,
    custom_template character varying(191),
    reading_time integer,
    comment_id character varying(191),
    published_at timestamp with time zone,
    updated_at timestamp with time zone,
    created_at timestamp with time zone,
    deleted_at timestamp with time zone,
    primary_author_id integer,
    primary_tag_id integer
);


ALTER TABLE public.posts OWNER TO postgres;

--
-- Name: posts_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.posts_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.posts_id_seq OWNER TO postgres;

--
-- Name: posts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.posts_id_seq OWNED BY public.posts.id;


--
-- Name: product_allergens; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.product_allergens (
    id integer NOT NULL,
    product_id integer NOT NULL,
    name character varying(255) NOT NULL,
    contains boolean DEFAULT false NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE public.product_allergens OWNER TO postgres;

--
-- Name: product_allergens_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.product_allergens_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.product_allergens_id_seq OWNER TO postgres;

--
-- Name: product_allergens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.product_allergens_id_seq OWNED BY public.product_allergens.id;


--
-- Name: product_attributes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.product_attributes (
    id integer NOT NULL,
    product_id integer NOT NULL,
    key character varying(255) NOT NULL,
    value text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE public.product_attributes OWNER TO postgres;

--
-- Name: product_attributes_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.product_attributes_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.product_attributes_id_seq OWNER TO postgres;

--
-- Name: product_attributes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.product_attributes_id_seq OWNED BY public.product_attributes.id;


--
-- Name: product_images; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.product_images (
    id integer NOT NULL,
    product_id integer NOT NULL,
    url text NOT NULL,
    "position" integer DEFAULT 0 NOT NULL,
    kind character varying(16) DEFAULT 'gallery'::character varying NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone,
    CONSTRAINT ck_product_images_position_nonneg CHECK (("position" >= 0))
);


ALTER TABLE public.product_images OWNER TO postgres;

--
-- Name: product_images_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.product_images_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.product_images_id_seq OWNER TO postgres;

--
-- Name: product_images_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.product_images_id_seq OWNED BY public.product_images.id;


--
-- Name: product_labels; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.product_labels (
    id integer NOT NULL,
    product_id integer NOT NULL,
    name character varying(255) NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE public.product_labels OWNER TO postgres;

--
-- Name: product_labels_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.product_labels_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.product_labels_id_seq OWNER TO postgres;

--
-- Name: product_labels_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.product_labels_id_seq OWNED BY public.product_labels.id;


--
-- Name: product_likes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.product_likes (
    user_id integer NOT NULL,
    id integer NOT NULL,
    product_slug character varying(255),
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE public.product_likes OWNER TO postgres;

--
-- Name: product_likes_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.product_likes_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.product_likes_id_seq OWNER TO postgres;

--
-- Name: product_likes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.product_likes_id_seq OWNED BY public.product_likes.id;


--
-- Name: product_logs; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.product_logs (
    id integer NOT NULL,
    slug character varying(255),
    href_tried text,
    ok boolean DEFAULT false NOT NULL,
    error_type character varying(255),
    error_message text,
    http_status integer,
    final_url text,
    transport_error boolean,
    title character varying(512),
    has_description_html boolean,
    has_description_short boolean,
    sections_count integer,
    images_count integer,
    embedded_images_count integer,
    all_images_count integer,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.product_logs OWNER TO postgres;

--
-- Name: product_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.product_logs_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.product_logs_id_seq OWNER TO postgres;

--
-- Name: product_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.product_logs_id_seq OWNED BY public.product_logs.id;


--
-- Name: product_nutrition; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.product_nutrition (
    id integer NOT NULL,
    product_id integer NOT NULL,
    key character varying(255) NOT NULL,
    value character varying(255),
    unit character varying(64),
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE public.product_nutrition OWNER TO postgres;

--
-- Name: product_nutrition_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.product_nutrition_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.product_nutrition_id_seq OWNER TO postgres;

--
-- Name: product_nutrition_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.product_nutrition_id_seq OWNED BY public.product_nutrition.id;


--
-- Name: product_sections; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.product_sections (
    id integer NOT NULL,
    product_id integer NOT NULL,
    title character varying(255) NOT NULL,
    html text NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE public.product_sections OWNER TO postgres;

--
-- Name: product_sections_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.product_sections_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.product_sections_id_seq OWNER TO postgres;

--
-- Name: product_sections_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.product_sections_id_seq OWNED BY public.product_sections.id;


--
-- Name: product_stickers; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.product_stickers (
    id integer NOT NULL,
    product_id integer NOT NULL,
    name character varying(255) NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE public.product_stickers OWNER TO postgres;

--
-- Name: product_stickers_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.product_stickers_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.product_stickers_id_seq OWNER TO postgres;

--
-- Name: product_stickers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.product_stickers_id_seq OWNED BY public.product_stickers.id;


--
-- Name: products; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.products (
    id integer NOT NULL,
    slug character varying(255) NOT NULL,
    title character varying(512),
    image text,
    description_short text,
    description_html text,
    suma_href text,
    brand character varying(255),
    rrp numeric(12,2),
    rrp_currency character varying(16),
    rrp_raw character varying(128),
    price_per_unit numeric(12,4),
    price_per_unit_currency character varying(16),
    price_per_unit_raw character varying(128),
    special_price numeric(12,2),
    special_price_currency character varying(16),
    special_price_raw character varying(128),
    case_size_count integer,
    case_size_item_qty numeric(12,3),
    case_size_item_unit character varying(32),
    case_size_raw character varying(128),
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone,
    ean character varying(64),
    sku character varying(128),
    unit_size character varying(128),
    pack_size character varying(128),
    regular_price numeric(12,2),
    regular_price_currency character varying(16),
    regular_price_raw character varying(128),
    oe_list_price numeric(12,2)
);


ALTER TABLE public.products OWNER TO postgres;

--
-- Name: products_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.products_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.products_id_seq OWNER TO postgres;

--
-- Name: products_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.products_id_seq OWNED BY public.products.id;


--
-- Name: subcategory_redirects; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.subcategory_redirects (
    id integer NOT NULL,
    old_path character varying(512) NOT NULL,
    new_path character varying(512) NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE public.subcategory_redirects OWNER TO postgres;

--
-- Name: subcategory_redirects_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.subcategory_redirects_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.subcategory_redirects_id_seq OWNER TO postgres;

--
-- Name: subcategory_redirects_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.subcategory_redirects_id_seq OWNED BY public.subcategory_redirects.id;


--
-- Name: tags; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.tags (
    id integer NOT NULL,
    ghost_id character varying(64) NOT NULL,
    slug character varying(191) NOT NULL,
    name character varying(255) NOT NULL,
    description text,
    visibility character varying(32) DEFAULT 'public'::character varying NOT NULL,
    feature_image text,
    meta_title character varying(300),
    meta_description text,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    deleted_at timestamp with time zone
);


ALTER TABLE public.tags OWNER TO postgres;

--
-- Name: tags_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.tags_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.tags_id_seq OWNER TO postgres;

--
-- Name: tags_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.tags_id_seq OWNED BY public.tags.id;


--
-- Name: user_labels; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.user_labels (
    id integer NOT NULL,
    user_id integer NOT NULL,
    label_id integer NOT NULL
);


ALTER TABLE public.user_labels OWNER TO postgres;

--
-- Name: user_labels_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.user_labels_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.user_labels_id_seq OWNER TO postgres;

--
-- Name: user_labels_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.user_labels_id_seq OWNED BY public.user_labels.id;


--
-- Name: user_newsletters; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.user_newsletters (
    id integer NOT NULL,
    user_id integer NOT NULL,
    newsletter_id integer NOT NULL,
    subscribed boolean DEFAULT true NOT NULL
);


ALTER TABLE public.user_newsletters OWNER TO postgres;

--
-- Name: user_newsletters_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.user_newsletters_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.user_newsletters_id_seq OWNER TO postgres;

--
-- Name: user_newsletters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.user_newsletters_id_seq OWNED BY public.user_newsletters.id;


--
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.users (
    id integer NOT NULL,
    email character varying(255) NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    last_login_at timestamp with time zone,
    ghost_id character varying(64),
    name character varying(255),
    ghost_status character varying(50),
    ghost_subscribed boolean DEFAULT true NOT NULL,
    ghost_note text,
    avatar_image text,
    stripe_customer_id character varying(255),
    ghost_raw jsonb
);


ALTER TABLE public.users OWNER TO postgres;

--
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.users_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.users_id_seq OWNER TO postgres;

--
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;


--
-- Name: authors id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: calendar_entries id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: calendar_slots id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: calendars id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: ghost_labels id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: ghost_newsletters id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: ghost_subscriptions id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: ghost_tiers id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: link_errors id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: link_externals id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: listing_items id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: listings id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: magic_links id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: nav_subs id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: nav_tops id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: posts id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: product_allergens id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: product_attributes id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: product_images id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: product_labels id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: product_likes id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: product_logs id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: product_nutrition id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: product_sections id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: product_stickers id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: products id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: subcategory_redirects id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: tags id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: user_labels id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: user_newsletters id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: users id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--


--
-- Name: authors authors_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.authors
    ADD CONSTRAINT authors_pkey PRIMARY KEY (id);


--
-- Name: calendar_entries calendar_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.calendar_entries
    ADD CONSTRAINT calendar_entries_pkey PRIMARY KEY (id);


--
-- Name: calendar_slots calendar_slots_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.calendar_slots
    ADD CONSTRAINT calendar_slots_pkey PRIMARY KEY (id);


--
-- Name: calendars calendars_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.calendars
    ADD CONSTRAINT calendars_pkey PRIMARY KEY (id);


--
-- Name: ghost_labels ghost_labels_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ghost_labels
    ADD CONSTRAINT ghost_labels_pkey PRIMARY KEY (id);


--
-- Name: ghost_newsletters ghost_newsletters_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ghost_newsletters
    ADD CONSTRAINT ghost_newsletters_pkey PRIMARY KEY (id);


--
-- Name: ghost_subscriptions ghost_subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ghost_subscriptions
    ADD CONSTRAINT ghost_subscriptions_pkey PRIMARY KEY (id);


--
-- Name: ghost_tiers ghost_tiers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ghost_tiers
    ADD CONSTRAINT ghost_tiers_pkey PRIMARY KEY (id);


--
-- Name: kv kv_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.kv
    ADD CONSTRAINT kv_pkey PRIMARY KEY (key);


--
-- Name: link_errors link_errors_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.link_errors
    ADD CONSTRAINT link_errors_pkey PRIMARY KEY (id);


--
-- Name: link_externals link_externals_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.link_externals
    ADD CONSTRAINT link_externals_pkey PRIMARY KEY (id);


--
-- Name: listing_items listing_items_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.listing_items
    ADD CONSTRAINT listing_items_pkey PRIMARY KEY (id);


--
-- Name: listings listings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.listings
    ADD CONSTRAINT listings_pkey PRIMARY KEY (id);


--
-- Name: magic_links magic_links_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.magic_links
    ADD CONSTRAINT magic_links_pkey PRIMARY KEY (id);


--
-- Name: magic_links magic_links_token_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.magic_links
    ADD CONSTRAINT magic_links_token_key UNIQUE (token);


--
-- Name: nav_subs nav_subs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.nav_subs
    ADD CONSTRAINT nav_subs_pkey PRIMARY KEY (id);


--
-- Name: nav_tops nav_tops_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.nav_tops
    ADD CONSTRAINT nav_tops_pkey PRIMARY KEY (id);


--
-- Name: post_authors post_authors_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.post_authors
    ADD CONSTRAINT post_authors_pkey PRIMARY KEY (post_id, author_id);


--
-- Name: post_tags post_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.post_tags
    ADD CONSTRAINT post_tags_pkey PRIMARY KEY (post_id, tag_id);


--
-- Name: posts posts_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.posts
    ADD CONSTRAINT posts_pkey PRIMARY KEY (id);


--
-- Name: product_allergens product_allergens_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_allergens
    ADD CONSTRAINT product_allergens_pkey PRIMARY KEY (id);


--
-- Name: product_attributes product_attributes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_attributes
    ADD CONSTRAINT product_attributes_pkey PRIMARY KEY (id);


--
-- Name: product_images product_images_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_images
    ADD CONSTRAINT product_images_pkey PRIMARY KEY (id);


--
-- Name: product_labels product_labels_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_labels
    ADD CONSTRAINT product_labels_pkey PRIMARY KEY (id);


--
-- Name: product_logs product_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_logs
    ADD CONSTRAINT product_logs_pkey PRIMARY KEY (id);


--
-- Name: product_nutrition product_nutrition_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_nutrition
    ADD CONSTRAINT product_nutrition_pkey PRIMARY KEY (id);


--
-- Name: product_sections product_sections_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_sections
    ADD CONSTRAINT product_sections_pkey PRIMARY KEY (id);


--
-- Name: product_stickers product_stickers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_stickers
    ADD CONSTRAINT product_stickers_pkey PRIMARY KEY (id);


--
-- Name: products products_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.products
    ADD CONSTRAINT products_pkey PRIMARY KEY (id);


--
-- Name: products products_slug_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.products
    ADD CONSTRAINT products_slug_deleted_at UNIQUE (slug, deleted_at);


--
-- Name: subcategory_redirects subcategory_redirects_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.subcategory_redirects
    ADD CONSTRAINT subcategory_redirects_pkey PRIMARY KEY (id);


--
-- Name: tags tags_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.tags
    ADD CONSTRAINT tags_pkey PRIMARY KEY (id);


--
-- Name: authors uq_authors_ghost_id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.authors
    ADD CONSTRAINT uq_authors_ghost_id UNIQUE (ghost_id);


--
-- Name: calendar_slots uq_calendar_slots_unique_band; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.calendar_slots
    ADD CONSTRAINT uq_calendar_slots_unique_band UNIQUE (calendar_id, name);


--
-- Name: listing_items uq_listing_items; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.listing_items
    ADD CONSTRAINT uq_listing_items UNIQUE (listing_id, slug, deleted_at);


--
-- Name: listing_items uq_listing_items_listing_slug; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.listing_items
    ADD CONSTRAINT uq_listing_items_listing_slug UNIQUE (listing_id, slug, deleted_at);


--
-- Name: listings uq_listings_top_sub; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.listings
    ADD CONSTRAINT uq_listings_top_sub UNIQUE (top_id, sub_id, deleted_at);



--
-- Name: nav_subs uq_nav_subs_top_slug; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.nav_subs
    ADD CONSTRAINT uq_nav_subs_top_slug UNIQUE (top_id, slug, deleted_at);




--
-- Name: nav_tops uq_nav_tops_label_slug; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.nav_tops
    ADD CONSTRAINT uq_nav_tops_label_slug UNIQUE (label, slug, deleted_at);


--
-- Name: posts uq_posts_ghost_id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.posts
    ADD CONSTRAINT uq_posts_ghost_id UNIQUE (ghost_id);


--
-- Name: posts uq_posts_uuid; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.posts
    ADD CONSTRAINT uq_posts_uuid UNIQUE (uuid);


--
-- Name: product_allergens uq_product_allergens_product_name; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_allergens
    ADD CONSTRAINT uq_product_allergens_product_name UNIQUE (product_id, name, deleted_at);


--
-- Name: product_attributes uq_product_attributes_product_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_attributes
    ADD CONSTRAINT uq_product_attributes_product_key UNIQUE (product_id, key, deleted_at);


--
-- Name: product_images uq_product_images_product_url_kind; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_images
    ADD CONSTRAINT uq_product_images_product_url_kind UNIQUE (product_id, url, kind, deleted_at);


--
-- Name: product_labels uq_product_labels_product_name; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_labels
    ADD CONSTRAINT uq_product_labels_product_name UNIQUE (product_id, name, deleted_at);


--
-- Name: product_likes uq_product_likes_product_user; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_likes
    ADD CONSTRAINT uq_product_likes_product_user UNIQUE (product_slug, user_id, deleted_at);


--
-- Name: product_nutrition uq_product_nutrition_product_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_nutrition
    ADD CONSTRAINT uq_product_nutrition_product_key UNIQUE (product_id, key, deleted_at);


--
-- Name: product_sections uq_product_sections_product_title; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_sections
    ADD CONSTRAINT uq_product_sections_product_title UNIQUE (product_id, title, deleted_at);


--
-- Name: product_stickers uq_product_stickers_product_name; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_stickers
    ADD CONSTRAINT uq_product_stickers_product_name UNIQUE (product_id, name, deleted_at);


--
-- Name: subcategory_redirects uq_subcategory_redirects_old_new; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.subcategory_redirects
    ADD CONSTRAINT uq_subcategory_redirects_old_new UNIQUE (old_path, new_path, deleted_at);


--
-- Name: tags uq_tags_ghost_id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.tags
    ADD CONSTRAINT uq_tags_ghost_id UNIQUE (ghost_id);


--
-- Name: user_labels uq_user_label; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_labels
    ADD CONSTRAINT uq_user_label UNIQUE (user_id, label_id);


--
-- Name: user_newsletters uq_user_newsletter; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_newsletters
    ADD CONSTRAINT uq_user_newsletter UNIQUE (user_id, newsletter_id);


--
-- Name: user_labels user_labels_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_labels
    ADD CONSTRAINT user_labels_pkey PRIMARY KEY (id);


--
-- Name: user_newsletters user_newsletters_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_newsletters
    ADD CONSTRAINT user_newsletters_pkey PRIMARY KEY (id);


--
-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_email_key UNIQUE (email);


--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_pkey PRIMARY KEY (id);


--
-- Name: ix_authors_ghost_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_authors_ghost_id ON public.authors USING btree (ghost_id);


--
-- Name: ix_authors_slug; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_authors_slug ON public.authors USING btree (slug);


--
-- Name: ix_calendar_entries_calendar_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_calendar_entries_calendar_id ON public.calendar_entries USING btree (calendar_id);


--
-- Name: ix_calendar_entries_name; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_calendar_entries_name ON public.calendar_entries USING btree (name);


--
-- Name: ix_calendar_entries_start_at; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_calendar_entries_start_at ON public.calendar_entries USING btree (start_at);


--
-- Name: ix_calendar_slots_calendar_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_calendar_slots_calendar_id ON public.calendar_slots USING btree (calendar_id);


--
-- Name: ix_calendar_slots_time_start; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_calendar_slots_time_start ON public.calendar_slots USING btree (time_start);


--
-- Name: ix_calendars_name; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_calendars_name ON public.calendars USING btree (name);


--
-- Name: ix_calendars_post_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_calendars_post_id ON public.calendars USING btree (post_id);


--
-- Name: ix_calendars_slug; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_calendars_slug ON public.calendars USING btree (slug);


--
-- Name: ix_ghost_labels_ghost_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE UNIQUE INDEX ix_ghost_labels_ghost_id ON public.ghost_labels USING btree (ghost_id);


--
-- Name: ix_ghost_newsletters_ghost_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE UNIQUE INDEX ix_ghost_newsletters_ghost_id ON public.ghost_newsletters USING btree (ghost_id);


--
-- Name: ix_ghost_subscriptions_ghost_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE UNIQUE INDEX ix_ghost_subscriptions_ghost_id ON public.ghost_subscriptions USING btree (ghost_id);


--
-- Name: ix_ghost_subscriptions_stripe_customer_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_ghost_subscriptions_stripe_customer_id ON public.ghost_subscriptions USING btree (stripe_customer_id);


--
-- Name: ix_ghost_subscriptions_stripe_subscription_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_ghost_subscriptions_stripe_subscription_id ON public.ghost_subscriptions USING btree (stripe_subscription_id);


--
-- Name: ix_ghost_subscriptions_tier_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_ghost_subscriptions_tier_id ON public.ghost_subscriptions USING btree (tier_id);


--
-- Name: ix_ghost_subscriptions_user_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_ghost_subscriptions_user_id ON public.ghost_subscriptions USING btree (user_id);


--
-- Name: ix_ghost_tiers_ghost_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE UNIQUE INDEX ix_ghost_tiers_ghost_id ON public.ghost_tiers USING btree (ghost_id);


--
-- Name: ix_link_errors_product_slug; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_link_errors_product_slug ON public.link_errors USING btree (product_slug);


--
-- Name: ix_link_externals_product_slug; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_link_externals_product_slug ON public.link_externals USING btree (product_slug);


--
-- Name: ix_listing_items_listing_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_listing_items_listing_id ON public.listing_items USING btree (listing_id);


--
-- Name: ix_listing_items_listing_slug; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_listing_items_listing_slug ON public.listing_items USING btree (listing_id, slug);


--
-- Name: ix_listing_items_slug; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_listing_items_slug ON public.listing_items USING btree (slug);


--
-- Name: ix_listings_sub_slug; Type: INDEX; Schema: public; Owner: postgres
--



--
-- Name: ix_listings_top_slug; Type: INDEX; Schema: public; Owner: postgres
--



--
-- Name: ix_magic_links_token; Type: INDEX; Schema: public; Owner: postgres
--

CREATE UNIQUE INDEX ix_magic_links_token ON public.magic_links USING btree (token);


--
-- Name: ix_magic_links_user; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_magic_links_user ON public.magic_links USING btree (user_id);


--
-- Name: ix_nav_subs_slug; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_nav_subs_slug ON public.nav_subs USING btree (slug);


--
-- Name: ix_nav_subs_top_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_nav_subs_top_id ON public.nav_subs USING btree (top_id);


--
-- Name: ix_nav_tops_slug; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_nav_tops_slug ON public.nav_tops USING btree (slug);


--
-- Name: ix_posts_ghost_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_posts_ghost_id ON public.posts USING btree (ghost_id);


--
-- Name: ix_posts_is_page; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_posts_is_page ON public.posts USING btree (is_page);


--
-- Name: ix_posts_published_at; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_posts_published_at ON public.posts USING btree (published_at);


--
-- Name: ix_posts_slug; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_posts_slug ON public.posts USING btree (slug);


--
-- Name: ix_posts_status; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_posts_status ON public.posts USING btree (status);


--
-- Name: ix_posts_visibility; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_posts_visibility ON public.posts USING btree (visibility);


--
-- Name: ix_product_allergens_name; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_allergens_name ON public.product_allergens USING btree (name);


--
-- Name: ix_product_allergens_product_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_allergens_product_id ON public.product_allergens USING btree (product_id);


--
-- Name: ix_product_attributes_key; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_attributes_key ON public.product_attributes USING btree (key);


--
-- Name: ix_product_attributes_product_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_attributes_product_id ON public.product_attributes USING btree (product_id);


--
-- Name: ix_product_images_position; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_images_position ON public.product_images USING btree ("position");


--
-- Name: ix_product_images_product_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_images_product_id ON public.product_images USING btree (product_id);


--
-- Name: ix_product_labels_name; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_labels_name ON public.product_labels USING btree (name);


--
-- Name: ix_product_labels_product_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_labels_product_id ON public.product_labels USING btree (product_id);


--
-- Name: ix_product_likes_product_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_likes_product_id ON public.product_likes USING btree (product_slug);


--
-- Name: ix_product_likes_user_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_likes_user_id ON public.product_likes USING btree (user_id);


--
-- Name: ix_product_likes_user_product; Type: INDEX; Schema: public; Owner: postgres
--

CREATE UNIQUE INDEX ix_product_likes_user_product ON public.product_likes USING btree (user_id, product_slug, deleted_at);


--
-- Name: ix_product_logs_slug; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_logs_slug ON public.product_logs USING btree (slug);


--
-- Name: ix_product_nutrition_key; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_nutrition_key ON public.product_nutrition USING btree (key);


--
-- Name: ix_product_nutrition_product_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_nutrition_product_id ON public.product_nutrition USING btree (product_id);


--
-- Name: ix_product_sections_product_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_sections_product_id ON public.product_sections USING btree (product_id);


--
-- Name: ix_product_stickers_name; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_stickers_name ON public.product_stickers USING btree (name);


--
-- Name: ix_product_stickers_product_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_product_stickers_product_id ON public.product_stickers USING btree (product_id);


--
-- Name: ix_products_brand; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_products_brand ON public.products USING btree (brand);


--
-- Name: ix_products_ean; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_products_ean ON public.products USING btree (ean);


--
-- Name: ix_products_regular_price; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_products_regular_price ON public.products USING btree (regular_price);


--
-- Name: ix_products_sku; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_products_sku ON public.products USING btree (sku);


--
-- Name: ix_products_slug; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_products_slug ON public.products USING btree (slug);


--
-- Name: ix_subcategory_redirects_old_path; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_subcategory_redirects_old_path ON public.subcategory_redirects USING btree (old_path);


--
-- Name: ix_tags_ghost_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_tags_ghost_id ON public.tags USING btree (ghost_id);


--
-- Name: ix_tags_slug; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_tags_slug ON public.tags USING btree (slug);


--
-- Name: ix_users_email; Type: INDEX; Schema: public; Owner: postgres
--

CREATE UNIQUE INDEX ix_users_email ON public.users USING btree (email);


--
-- Name: ix_users_ghost_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE UNIQUE INDEX ix_users_ghost_id ON public.users USING btree (ghost_id);


--
-- Name: ix_users_stripe_customer_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_users_stripe_customer_id ON public.users USING btree (stripe_customer_id);


--
-- Name: ux_calendars_post_slug_active; Type: INDEX; Schema: public; Owner: postgres
--

CREATE UNIQUE INDEX ux_calendars_post_slug_active ON public.calendars USING btree (post_id, lower((slug)::text)) WHERE (deleted_at IS NULL);


--
-- Name: calendar_entries calendar_entries_calendar_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.calendar_entries
    ADD CONSTRAINT calendar_entries_calendar_id_fkey FOREIGN KEY (calendar_id) REFERENCES public.calendars(id) ON DELETE CASCADE;


--
-- Name: calendar_slots calendar_slots_calendar_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.calendar_slots
    ADD CONSTRAINT calendar_slots_calendar_id_fkey FOREIGN KEY (calendar_id) REFERENCES public.calendars(id) ON DELETE CASCADE;


--
-- Name: calendars calendars_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.calendars
    ADD CONSTRAINT calendars_post_id_fkey FOREIGN KEY (post_id) REFERENCES public.posts(id) ON DELETE CASCADE;


--
-- Name: product_likes fk_product_likes_product_id_products; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_likes
    ADD CONSTRAINT fk_product_likes_product_id_products FOREIGN KEY (product_slug) REFERENCES public.products(slug) ON DELETE CASCADE;


--
-- Name: ghost_subscriptions ghost_subscriptions_tier_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ghost_subscriptions
    ADD CONSTRAINT ghost_subscriptions_tier_id_fkey FOREIGN KEY (tier_id) REFERENCES public.ghost_tiers(id) ON DELETE SET NULL;


--
-- Name: ghost_subscriptions ghost_subscriptions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ghost_subscriptions
    ADD CONSTRAINT ghost_subscriptions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: listing_items listing_items_listing_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.listing_items
    ADD CONSTRAINT listing_items_listing_id_fkey FOREIGN KEY (listing_id) REFERENCES public.listings(id) ON DELETE CASCADE;


--
-- Name: listings listings_sub_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.listings
    ADD CONSTRAINT listings_sub_id_fkey FOREIGN KEY (sub_id) REFERENCES public.nav_subs(id);


--
-- Name: listings listings_top_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.listings
    ADD CONSTRAINT listings_top_id_fkey FOREIGN KEY (top_id) REFERENCES public.nav_tops(id);


--
-- Name: magic_links magic_links_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.magic_links
    ADD CONSTRAINT magic_links_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: nav_subs nav_subs_top_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.nav_subs
    ADD CONSTRAINT nav_subs_top_id_fkey FOREIGN KEY (top_id) REFERENCES public.nav_tops(id) ON DELETE CASCADE;


--
-- Name: post_authors post_authors_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.post_authors
    ADD CONSTRAINT post_authors_author_id_fkey FOREIGN KEY (author_id) REFERENCES public.authors(id) ON DELETE CASCADE;


--
-- Name: post_authors post_authors_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.post_authors
    ADD CONSTRAINT post_authors_post_id_fkey FOREIGN KEY (post_id) REFERENCES public.posts(id) ON DELETE CASCADE;


--
-- Name: post_tags post_tags_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.post_tags
    ADD CONSTRAINT post_tags_post_id_fkey FOREIGN KEY (post_id) REFERENCES public.posts(id) ON DELETE CASCADE;


--
-- Name: post_tags post_tags_tag_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.post_tags
    ADD CONSTRAINT post_tags_tag_id_fkey FOREIGN KEY (tag_id) REFERENCES public.tags(id) ON DELETE CASCADE;


--
-- Name: posts posts_primary_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.posts
    ADD CONSTRAINT posts_primary_author_id_fkey FOREIGN KEY (primary_author_id) REFERENCES public.authors(id) ON DELETE SET NULL;


--
-- Name: posts posts_primary_tag_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.posts
    ADD CONSTRAINT posts_primary_tag_id_fkey FOREIGN KEY (primary_tag_id) REFERENCES public.tags(id) ON DELETE SET NULL;


--
-- Name: product_allergens product_allergens_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_allergens
    ADD CONSTRAINT product_allergens_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(id) ON DELETE CASCADE;


--
-- Name: product_attributes product_attributes_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_attributes
    ADD CONSTRAINT product_attributes_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(id) ON DELETE CASCADE;


--
-- Name: product_images product_images_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_images
    ADD CONSTRAINT product_images_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(id) ON DELETE CASCADE;


--
-- Name: product_labels product_labels_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_labels
    ADD CONSTRAINT product_labels_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(id) ON DELETE CASCADE;


--
-- Name: product_likes product_likes_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_likes
    ADD CONSTRAINT product_likes_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: product_nutrition product_nutrition_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_nutrition
    ADD CONSTRAINT product_nutrition_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(id) ON DELETE CASCADE;


--
-- Name: product_sections product_sections_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_sections
    ADD CONSTRAINT product_sections_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(id) ON DELETE CASCADE;


--
-- Name: product_stickers product_stickers_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.product_stickers
    ADD CONSTRAINT product_stickers_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(id) ON DELETE CASCADE;


--
-- Name: user_labels user_labels_label_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_labels
    ADD CONSTRAINT user_labels_label_id_fkey FOREIGN KEY (label_id) REFERENCES public.ghost_labels(id) ON DELETE CASCADE;


--
-- Name: user_labels user_labels_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_labels
    ADD CONSTRAINT user_labels_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: user_newsletters user_newsletters_newsletter_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_newsletters
    ADD CONSTRAINT user_newsletters_newsletter_id_fkey FOREIGN KEY (newsletter_id) REFERENCES public.ghost_newsletters(id) ON DELETE CASCADE;


--
-- Name: user_newsletters user_newsletters_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_newsletters
    ADD CONSTRAINT user_newsletters_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--


