myheats

Live heats, scoring and leaderboard for sport events
git clone https://git.in0rdr.ch/myheats.git
Log | Files | Refs | Pull requests | README | LICENSE

scores.sql (3461B)


      1 --
      2 -- PostgreSQL database dump
      3 --
      4 
      5 -- Dumped from database version 15.1
      6 -- Dumped by pg_dump version 15.3
      7 
      8 SET statement_timeout = 0;
      9 SET lock_timeout = 0;
     10 SET idle_in_transaction_session_timeout = 0;
     11 SET client_encoding = 'UTF8';
     12 SET standard_conforming_strings = on;
     13 SELECT pg_catalog.set_config('search_path', '', false);
     14 SET check_function_bodies = false;
     15 SET xmloption = content;
     16 SET client_min_messages = warning;
     17 SET row_security = off;
     18 
     19 SET default_tablespace = '';
     20 
     21 SET default_table_access_method = heap;
     22 
     23 --
     24 -- Name: scores; Type: TABLE; Schema: public; Owner: postgres
     25 --
     26 
     27 CREATE TABLE public.scores (
     28     id bigint NOT NULL,
     29     created_at timestamp with time zone DEFAULT now(),
     30     athlete bigint NOT NULL,
     31     judge uuid NOT NULL,
     32     score double precision,
     33     heat bigint NOT NULL
     34 );
     35 
     36 
     37 ALTER TABLE public.scores OWNER TO postgres;
     38 
     39 --
     40 -- Name: TABLE scores; Type: COMMENT; Schema: public; Owner: postgres
     41 --
     42 
     43 COMMENT ON TABLE public.scores IS 'List of scores';
     44 
     45 
     46 --
     47 -- Name: score_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
     48 --
     49 
     50 ALTER TABLE public.scores ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
     51     SEQUENCE NAME public.score_id_seq
     52     START WITH 1
     53     INCREMENT BY 1
     54     NO MINVALUE
     55     NO MAXVALUE
     56     CACHE 1
     57 );
     58 
     59 
     60 --
     61 -- Name: scores scores_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
     62 --
     63 
     64 ALTER TABLE ONLY public.scores
     65     ADD CONSTRAINT scores_pkey PRIMARY KEY (athlete, judge, heat);
     66 
     67 
     68 --
     69 -- Name: scores scores_athlete_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
     70 --
     71 
     72 ALTER TABLE ONLY public.scores
     73     ADD CONSTRAINT scores_athlete_fkey FOREIGN KEY (athlete) REFERENCES public.athletes(id) ON DELETE CASCADE;
     74 
     75 
     76 --
     77 -- Name: scores scores_heat_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
     78 --
     79 
     80 ALTER TABLE ONLY public.scores
     81     ADD CONSTRAINT scores_heat_fkey FOREIGN KEY (heat) REFERENCES public.heats(id) ON DELETE CASCADE;
     82 
     83 
     84 --
     85 -- Name: scores scores_judge_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
     86 --
     87 
     88 ALTER TABLE ONLY public.scores
     89     ADD CONSTRAINT scores_judge_fkey FOREIGN KEY (judge) REFERENCES public.judges(id) ON DELETE CASCADE;
     90 
     91 
     92 --
     93 -- Name: scores Enable insert for authenticated users only; Type: POLICY; Schema: public; Owner: postgres
     94 --
     95 
     96 CREATE POLICY "Enable insert for authenticated users only" ON public.scores FOR INSERT TO authenticated WITH CHECK (true);
     97 
     98 
     99 --
    100 -- Name: scores Enable judges to update their own scores; Type: POLICY; Schema: public; Owner: postgres
    101 --
    102 
    103 CREATE POLICY "Enable judges to update their own scores" ON public.scores FOR UPDATE USING ((auth.uid() = judge));
    104 
    105 
    106 --
    107 -- Name: scores Enable read access for all users; Type: POLICY; Schema: public; Owner: postgres
    108 --
    109 
    110 CREATE POLICY "Enable read access for all users" ON public.scores FOR SELECT USING (true);
    111 
    112 
    113 --
    114 -- Name: scores; Type: ROW SECURITY; Schema: public; Owner: postgres
    115 --
    116 
    117 ALTER TABLE public.scores ENABLE ROW LEVEL SECURITY;
    118 
    119 --
    120 -- Name: TABLE scores; Type: ACL; Schema: public; Owner: postgres
    121 --
    122 
    123 GRANT ALL ON TABLE public.scores TO anon;
    124 GRANT ALL ON TABLE public.scores TO authenticated;
    125 GRANT ALL ON TABLE public.scores TO service_role;
    126 
    127 
    128 --
    129 -- Name: SEQUENCE score_id_seq; Type: ACL; Schema: public; Owner: postgres
    130 --
    131 
    132 GRANT ALL ON SEQUENCE public.score_id_seq TO anon;
    133 GRANT ALL ON SEQUENCE public.score_id_seq TO authenticated;
    134 GRANT ALL ON SEQUENCE public.score_id_seq TO service_role;
    135 
    136 
    137 --
    138 -- PostgreSQL database dump complete
    139 --
    140