myheats

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

04-startlist.sql (765B)


      1 CREATE TABLE public.startlist (
      2     id bigint NOT NULL,
      3     created_at timestamp with time zone DEFAULT now(),
      4     heat bigint NOT NULL,
      5     athlete bigint NOT NULL
      6 );
      7 
      8 ALTER TABLE public.startlist ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
      9     SEQUENCE NAME public.startlist_id_seq
     10     START WITH 1
     11     INCREMENT BY 1
     12     NO MINVALUE
     13     NO MAXVALUE
     14     CACHE 1
     15 );
     16 
     17 ALTER TABLE ONLY public.startlist
     18     ADD CONSTRAINT startlist_pkey PRIMARY KEY (heat, athlete);
     19 
     20 ALTER TABLE ONLY public.startlist
     21     ADD CONSTRAINT startlist_athlete_fkey FOREIGN KEY (athlete) REFERENCES public.athletes(id) ON DELETE CASCADE;
     22 
     23 ALTER TABLE ONLY public.startlist
     24     ADD CONSTRAINT startlist_heat_fkey FOREIGN KEY (heat) REFERENCES public.heats(id) ON DELETE CASCADE;