ratings.sql (3487B)
1 -- 2 -- PostgreSQL database dump 3 -- 4 5 -- Dumped from database version 15.1 6 -- Dumped by pg_dump version 15.2 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: ratings; Type: TABLE; Schema: public; Owner: postgres 25 -- 26 27 CREATE TABLE public.ratings ( 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 rating double precision, 33 heat bigint NOT NULL 34 ); 35 36 37 ALTER TABLE public.ratings OWNER TO postgres; 38 39 -- 40 -- Name: TABLE ratings; Type: COMMENT; Schema: public; Owner: postgres 41 -- 42 43 COMMENT ON TABLE public.ratings IS 'List of ratings'; 44 45 46 -- 47 -- Name: rating_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres 48 -- 49 50 ALTER TABLE public.ratings ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY ( 51 SEQUENCE NAME public.rating_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: ratings ratings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres 62 -- 63 64 ALTER TABLE ONLY public.ratings 65 ADD CONSTRAINT ratings_pkey PRIMARY KEY (athlete, judge, heat); 66 67 68 -- 69 -- Name: ratings ratings_athlete_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres 70 -- 71 72 ALTER TABLE ONLY public.ratings 73 ADD CONSTRAINT ratings_athlete_fkey FOREIGN KEY (athlete) REFERENCES public.athletes(id) ON DELETE CASCADE; 74 75 76 -- 77 -- Name: ratings ratings_heat_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres 78 -- 79 80 ALTER TABLE ONLY public.ratings 81 ADD CONSTRAINT ratings_heat_fkey FOREIGN KEY (heat) REFERENCES public.heats(id) ON DELETE CASCADE; 82 83 84 -- 85 -- Name: ratings ratings_judge_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres 86 -- 87 88 ALTER TABLE ONLY public.ratings 89 ADD CONSTRAINT ratings_judge_fkey FOREIGN KEY (judge) REFERENCES public.judges(id); 90 91 92 -- 93 -- Name: ratings 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.ratings FOR INSERT TO authenticated WITH CHECK (true); 97 98 99 -- 100 -- Name: ratings Enable judges to update their own ratings; Type: POLICY; Schema: public; Owner: postgres 101 -- 102 103 CREATE POLICY "Enable judges to update their own ratings" ON public.ratings FOR UPDATE USING ((auth.uid() = judge)); 104 105 106 -- 107 -- Name: ratings 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.ratings FOR SELECT USING (true); 111 112 113 -- 114 -- Name: ratings; Type: ROW SECURITY; Schema: public; Owner: postgres 115 -- 116 117 ALTER TABLE public.ratings ENABLE ROW LEVEL SECURITY; 118 119 -- 120 -- Name: TABLE ratings; Type: ACL; Schema: public; Owner: postgres 121 -- 122 123 GRANT ALL ON TABLE public.ratings TO anon; 124 GRANT ALL ON TABLE public.ratings TO authenticated; 125 GRANT ALL ON TABLE public.ratings TO service_role; 126 127 128 -- 129 -- Name: SEQUENCE rating_id_seq; Type: ACL; Schema: public; Owner: postgres 130 -- 131 132 GRANT ALL ON SEQUENCE public.rating_id_seq TO anon; 133 GRANT ALL ON SEQUENCE public.rating_id_seq TO authenticated; 134 GRANT ALL ON SEQUENCE public.rating_id_seq TO service_role; 135 136 137 -- 138 -- PostgreSQL database dump complete 139 -- 140