|
| 1 | +CREATE TABLE public.team_members ( |
| 2 | + id integer NOT NULL, |
| 3 | + "teamId" integer NOT NULL, |
| 4 | + "userId" integer NOT NULL |
| 5 | +); |
| 6 | +CREATE TABLE public.teams ( |
| 7 | + id integer NOT NULL, |
| 8 | + name text NOT NULL, |
| 9 | + description text NOT NULL |
| 10 | +); |
| 11 | +CREATE TABLE public.challenges ( |
| 12 | + id integer NOT NULL, |
| 13 | + description text NOT NULL, |
| 14 | + "createdByUserId" integer NOT NULL, |
| 15 | + name text |
| 16 | +); |
| 17 | +CREATE SEQUENCE public.challenges_id_seq |
| 18 | + AS integer |
| 19 | + START WITH 1 |
| 20 | + INCREMENT BY 1 |
| 21 | + NO MINVALUE |
| 22 | + NO MAXVALUE |
| 23 | + CACHE 1; |
| 24 | +ALTER SEQUENCE public.challenges_id_seq OWNED BY public.challenges.id; |
| 25 | +CREATE SEQUENCE public.team_id_seq |
| 26 | + AS integer |
| 27 | + START WITH 1 |
| 28 | + INCREMENT BY 1 |
| 29 | + NO MINVALUE |
| 30 | + NO MAXVALUE |
| 31 | + CACHE 1; |
| 32 | +ALTER SEQUENCE public.team_id_seq OWNED BY public.teams.id; |
| 33 | +CREATE SEQUENCE public.team_members_id_seq |
| 34 | + AS integer |
| 35 | + START WITH 1 |
| 36 | + INCREMENT BY 1 |
| 37 | + NO MINVALUE |
| 38 | + NO MAXVALUE |
| 39 | + CACHE 1; |
| 40 | +ALTER SEQUENCE public.team_members_id_seq OWNED BY public.team_members.id; |
| 41 | +CREATE TABLE public.teams_challenges ( |
| 42 | + id integer NOT NULL, |
| 43 | + "teamId" integer NOT NULL, |
| 44 | + "challengeId" integer NOT NULL |
| 45 | +); |
| 46 | +CREATE SEQUENCE public.teams_challenges_id_seq |
| 47 | + AS integer |
| 48 | + START WITH 1 |
| 49 | + INCREMENT BY 1 |
| 50 | + NO MINVALUE |
| 51 | + NO MAXVALUE |
| 52 | + CACHE 1; |
| 53 | +ALTER SEQUENCE public.teams_challenges_id_seq OWNED BY public.teams_challenges.id; |
| 54 | +CREATE TABLE public.users ( |
| 55 | + id integer NOT NULL, |
| 56 | + email text NOT NULL, |
| 57 | + password text NOT NULL, |
| 58 | + role text, |
| 59 | + name text |
| 60 | +); |
| 61 | +CREATE SEQUENCE public.users_id_seq |
| 62 | + AS integer |
| 63 | + START WITH 1 |
| 64 | + INCREMENT BY 1 |
| 65 | + NO MINVALUE |
| 66 | + NO MAXVALUE |
| 67 | + CACHE 1; |
| 68 | +ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; |
| 69 | +ALTER TABLE ONLY public.challenges ALTER COLUMN id SET DEFAULT nextval('public.challenges_id_seq'::regclass); |
| 70 | +ALTER TABLE ONLY public.team_members ALTER COLUMN id SET DEFAULT nextval('public.team_members_id_seq'::regclass); |
| 71 | +ALTER TABLE ONLY public.teams ALTER COLUMN id SET DEFAULT nextval('public.team_id_seq'::regclass); |
| 72 | +ALTER TABLE ONLY public.teams_challenges ALTER COLUMN id SET DEFAULT nextval('public.teams_challenges_id_seq'::regclass); |
| 73 | +ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); |
| 74 | +ALTER TABLE ONLY public.challenges |
| 75 | + ADD CONSTRAINT challenges_pkey PRIMARY KEY (id); |
| 76 | +ALTER TABLE ONLY public.team_members |
| 77 | + ADD CONSTRAINT team_members_pkey PRIMARY KEY (id); |
| 78 | +ALTER TABLE ONLY public.teams |
| 79 | + ADD CONSTRAINT team_pkey PRIMARY KEY (id); |
| 80 | +ALTER TABLE ONLY public.teams_challenges |
| 81 | + ADD CONSTRAINT teams_challenges_pkey PRIMARY KEY (id); |
| 82 | +ALTER TABLE ONLY public.users |
| 83 | + ADD CONSTRAINT users_pkey PRIMARY KEY (id); |
| 84 | +ALTER TABLE ONLY public.challenges |
| 85 | + ADD CONSTRAINT "challenges_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES public.users(id) ON UPDATE RESTRICT ON DELETE RESTRICT; |
| 86 | +ALTER TABLE ONLY public.team_members |
| 87 | + ADD CONSTRAINT "team_members_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES public.teams(id) ON UPDATE RESTRICT ON DELETE RESTRICT; |
| 88 | +ALTER TABLE ONLY public.team_members |
| 89 | + ADD CONSTRAINT "team_members_userId_fkey" FOREIGN KEY ("userId") REFERENCES public.users(id) ON UPDATE RESTRICT ON DELETE RESTRICT; |
| 90 | +ALTER TABLE ONLY public.teams_challenges |
| 91 | + ADD CONSTRAINT "teams_challenges_challengeId_fkey" FOREIGN KEY ("challengeId") REFERENCES public.challenges(id) ON UPDATE RESTRICT ON DELETE RESTRICT; |
| 92 | +ALTER TABLE ONLY public.teams_challenges |
| 93 | + ADD CONSTRAINT "teams_challenges_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES public.teams(id) ON UPDATE RESTRICT ON DELETE RESTRICT; |
0 commit comments