--
-- PostgreSQL database dump
--

-- Dumped from database version 15.8 (Debian 15.8-1.pgdg110+1)
-- Dumped by pg_dump version 15.8 (Debian 15.8-1.pgdg110+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: tiger; Type: SCHEMA; Schema: -; Owner: teeoff_admin
--

CREATE SCHEMA tiger;


ALTER SCHEMA tiger OWNER TO teeoff_admin;

--
-- Name: tiger_data; Type: SCHEMA; Schema: -; Owner: teeoff_admin
--

CREATE SCHEMA tiger_data;


ALTER SCHEMA tiger_data OWNER TO teeoff_admin;

--
-- Name: topology; Type: SCHEMA; Schema: -; Owner: teeoff_admin
--

CREATE SCHEMA topology;


ALTER SCHEMA topology OWNER TO teeoff_admin;

--
-- Name: SCHEMA topology; Type: COMMENT; Schema: -; Owner: teeoff_admin
--

COMMENT ON SCHEMA topology IS 'PostGIS Topology schema';


--
-- Name: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS fuzzystrmatch WITH SCHEMA public;


--
-- Name: EXTENSION fuzzystrmatch; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION fuzzystrmatch IS 'determine similarities and distance between strings';


--
-- Name: postgis; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;


--
-- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION postgis IS 'PostGIS geometry and geography spatial types and functions';


--
-- Name: postgis_tiger_geocoder; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder WITH SCHEMA tiger;


--
-- Name: EXTENSION postgis_tiger_geocoder; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION postgis_tiger_geocoder IS 'PostGIS tiger geocoder and reverse geocoder';


--
-- Name: postgis_topology; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS postgis_topology WITH SCHEMA topology;


--
-- Name: EXTENSION postgis_topology; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION postgis_topology IS 'PostGIS topology spatial types and functions';


SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: courses; Type: TABLE; Schema: public; Owner: teeoff_admin
--

CREATE TABLE public.courses (
    id integer NOT NULL,
    facility_id integer,
    name character varying(255) NOT NULL,
    holes integer,
    par integer,
    length_meters integer,
    course_type character varying(255),
    architect character varying(255),
    status character varying(255),
    is_main_course boolean DEFAULT true,
    created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
    tee_boxes jsonb
);


ALTER TABLE public.courses OWNER TO teeoff_admin;

--
-- Name: courses_id_seq; Type: SEQUENCE; Schema: public; Owner: teeoff_admin
--

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


ALTER TABLE public.courses_id_seq OWNER TO teeoff_admin;

--
-- Name: courses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: teeoff_admin
--

ALTER SEQUENCE public.courses_id_seq OWNED BY public.courses.id;


--
-- Name: facilities; Type: TABLE; Schema: public; Owner: teeoff_admin
--

CREATE TABLE public.facilities (
    id integer NOT NULL,
    name character varying(255) NOT NULL,
    slug character varying(255) NOT NULL,
    description text,
    established_year integer,
    season character varying(255),
    address character varying(255),
    zipcode character varying(50),
    city character varying(255),
    county character varying(255),
    lat double precision,
    lng double precision,
    email character varying(255),
    phone character varying(255),
    website_url character varying(255),
    golfbox_booking_url character varying(255),
    golfbox_tournament_url character varying(255),
    facebook_url character varying(255),
    instagram_url character varying(255),
    weather_url character varying(255),
    webcam_url character varying(255),
    golfamore boolean DEFAULT false,
    created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
    image_url character varying(500),
    amenities jsonb,
    greenfee jsonb,
    architect text,
    membership jsonb,
    vtg jsonb,
    video_url text,
    baneguide_url text,
    logo_url text,
    flyfoto_url text,
    guest_requirements text,
    status_updated_at text,
    gallery jsonb
);


ALTER TABLE public.facilities OWNER TO teeoff_admin;

--
-- Name: facilities_id_seq; Type: SEQUENCE; Schema: public; Owner: teeoff_admin
--

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


ALTER TABLE public.facilities_id_seq OWNER TO teeoff_admin;

--
-- Name: facilities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: teeoff_admin
--

ALTER SEQUENCE public.facilities_id_seq OWNED BY public.facilities.id;


--
-- Name: facility_images; Type: TABLE; Schema: public; Owner: teeoff_admin
--

CREATE TABLE public.facility_images (
    id integer NOT NULL,
    facility_id integer,
    image_url character varying(255) NOT NULL,
    display_order integer DEFAULT 0,
    sort_order integer DEFAULT 0
);


ALTER TABLE public.facility_images OWNER TO teeoff_admin;

--
-- Name: facility_images_id_seq; Type: SEQUENCE; Schema: public; Owner: teeoff_admin
--

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


ALTER TABLE public.facility_images_id_seq OWNER TO teeoff_admin;

--
-- Name: facility_images_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: teeoff_admin
--

ALTER SEQUENCE public.facility_images_id_seq OWNED BY public.facility_images.id;


--
-- Name: hole_lengths; Type: TABLE; Schema: public; Owner: teeoff_admin
--

CREATE TABLE public.hole_lengths (
    id integer NOT NULL,
    hole_id integer,
    tee_id integer,
    length_meters integer
);


ALTER TABLE public.hole_lengths OWNER TO teeoff_admin;

--
-- Name: hole_lengths_id_seq; Type: SEQUENCE; Schema: public; Owner: teeoff_admin
--

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


ALTER TABLE public.hole_lengths_id_seq OWNER TO teeoff_admin;

--
-- Name: hole_lengths_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: teeoff_admin
--

ALTER SEQUENCE public.hole_lengths_id_seq OWNED BY public.hole_lengths.id;


--
-- Name: holes; Type: TABLE; Schema: public; Owner: teeoff_admin
--

CREATE TABLE public.holes (
    id integer NOT NULL,
    course_id integer,
    hole_number integer NOT NULL,
    par integer,
    hcp_index integer,
    lengths jsonb
);


ALTER TABLE public.holes OWNER TO teeoff_admin;

--
-- Name: holes_id_seq; Type: SEQUENCE; Schema: public; Owner: teeoff_admin
--

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


ALTER TABLE public.holes_id_seq OWNER TO teeoff_admin;

--
-- Name: holes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: teeoff_admin
--

ALTER SEQUENCE public.holes_id_seq OWNED BY public.holes.id;


--
-- Name: tees; Type: TABLE; Schema: public; Owner: teeoff_admin
--

CREATE TABLE public.tees (
    id integer NOT NULL,
    course_id integer,
    name character varying(50) NOT NULL,
    cr_men numeric(4,1),
    slope_men integer,
    cr_women numeric(4,1),
    slope_women integer
);


ALTER TABLE public.tees OWNER TO teeoff_admin;

--
-- Name: tees_id_seq; Type: SEQUENCE; Schema: public; Owner: teeoff_admin
--

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


ALTER TABLE public.tees_id_seq OWNER TO teeoff_admin;

--
-- Name: tees_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: teeoff_admin
--

ALTER SEQUENCE public.tees_id_seq OWNED BY public.tees.id;


--
-- Name: courses id; Type: DEFAULT; Schema: public; Owner: teeoff_admin
--

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


--
-- Name: facilities id; Type: DEFAULT; Schema: public; Owner: teeoff_admin
--

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


--
-- Name: facility_images id; Type: DEFAULT; Schema: public; Owner: teeoff_admin
--

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


--
-- Name: hole_lengths id; Type: DEFAULT; Schema: public; Owner: teeoff_admin
--

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


--
-- Name: holes id; Type: DEFAULT; Schema: public; Owner: teeoff_admin
--

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


--
-- Name: tees id; Type: DEFAULT; Schema: public; Owner: teeoff_admin
--

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


--
-- Name: courses courses_pkey; Type: CONSTRAINT; Schema: public; Owner: teeoff_admin
--

ALTER TABLE ONLY public.courses
    ADD CONSTRAINT courses_pkey PRIMARY KEY (id);


--
-- Name: facilities facilities_pkey; Type: CONSTRAINT; Schema: public; Owner: teeoff_admin
--

ALTER TABLE ONLY public.facilities
    ADD CONSTRAINT facilities_pkey PRIMARY KEY (id);


--
-- Name: facilities facilities_slug_key; Type: CONSTRAINT; Schema: public; Owner: teeoff_admin
--

ALTER TABLE ONLY public.facilities
    ADD CONSTRAINT facilities_slug_key UNIQUE (slug);


--
-- Name: facility_images facility_images_pkey; Type: CONSTRAINT; Schema: public; Owner: teeoff_admin
--

ALTER TABLE ONLY public.facility_images
    ADD CONSTRAINT facility_images_pkey PRIMARY KEY (id);


--
-- Name: hole_lengths hole_lengths_pkey; Type: CONSTRAINT; Schema: public; Owner: teeoff_admin
--

ALTER TABLE ONLY public.hole_lengths
    ADD CONSTRAINT hole_lengths_pkey PRIMARY KEY (id);


--
-- Name: holes holes_pkey; Type: CONSTRAINT; Schema: public; Owner: teeoff_admin
--

ALTER TABLE ONLY public.holes
    ADD CONSTRAINT holes_pkey PRIMARY KEY (id);


--
-- Name: tees tees_pkey; Type: CONSTRAINT; Schema: public; Owner: teeoff_admin
--

ALTER TABLE ONLY public.tees
    ADD CONSTRAINT tees_pkey PRIMARY KEY (id);


--
-- Name: courses courses_facility_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: teeoff_admin
--

ALTER TABLE ONLY public.courses
    ADD CONSTRAINT courses_facility_id_fkey FOREIGN KEY (facility_id) REFERENCES public.facilities(id) ON DELETE CASCADE;


--
-- Name: hole_lengths hole_lengths_hole_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: teeoff_admin
--

ALTER TABLE ONLY public.hole_lengths
    ADD CONSTRAINT hole_lengths_hole_id_fkey FOREIGN KEY (hole_id) REFERENCES public.holes(id) ON DELETE CASCADE;


--
-- Name: hole_lengths hole_lengths_tee_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: teeoff_admin
--

ALTER TABLE ONLY public.hole_lengths
    ADD CONSTRAINT hole_lengths_tee_id_fkey FOREIGN KEY (tee_id) REFERENCES public.tees(id) ON DELETE CASCADE;


--
-- Name: holes holes_course_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: teeoff_admin
--

ALTER TABLE ONLY public.holes
    ADD CONSTRAINT holes_course_id_fkey FOREIGN KEY (course_id) REFERENCES public.courses(id) ON DELETE CASCADE;


--
-- Name: tees tees_course_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: teeoff_admin
--

ALTER TABLE ONLY public.tees
    ADD CONSTRAINT tees_course_id_fkey FOREIGN KEY (course_id) REFERENCES public.courses(id) ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--

