database.sql 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. -- Table: public."user"
  2. -- DROP TABLE public."user";
  3. CREATE TABLE public."user"
  4. (
  5. id serial,
  6. username text NOT NULL,
  7. password character varying,
  8. CONSTRAINT user_pkey PRIMARY KEY (id)
  9. );
  10. -- Index: user_lower_idx
  11. -- DROP INDEX public.user_lower_idx;
  12. CREATE UNIQUE INDEX user_lower_idx
  13. ON public."user"
  14. (lower(username));
  15. -- Table: public.panel
  16. -- DROP TABLE public.panel;
  17. CREATE TABLE public.panel
  18. (
  19. id serial,
  20. name text NOT NULL,
  21. article text NOT NULL,
  22. CONSTRAINT panel_pkey PRIMARY KEY (id)
  23. );
  24. -- Table: public.user_panel
  25. -- DROP TABLE public.user_panel;
  26. CREATE TABLE public.user_panel
  27. (
  28. user_id integer NOT NULL,
  29. panel_id integer NOT NULL,
  30. CONSTRAINT user_panel_pkey PRIMARY KEY (user_id, panel_id),
  31. CONSTRAINT panel_id FOREIGN KEY (user_id)
  32. REFERENCES public.panel (id),
  33. CONSTRAINT user_id FOREIGN KEY (user_id)
  34. REFERENCES public."user" (id)
  35. );
  36. -- Table: public.round
  37. -- DROP TABLE public.round;
  38. CREATE TABLE public.round
  39. (
  40. id serial,
  41. start timestamp with time zone NOT NULL,
  42. "end" timestamp with time zone NOT NULL,
  43. panel_id integer NOT NULL,
  44. section text NOT NULL,
  45. CONSTRAINT round_pkey PRIMARY KEY (id),
  46. CONSTRAINT panel_id FOREIGN KEY (panel_id)
  47. REFERENCES public.panel (id)
  48. );
  49. -- Table: public.entry
  50. -- DROP TABLE public.entry;
  51. CREATE TABLE public.entry
  52. (
  53. user_id integer NOT NULL,
  54. round_id integer NOT NULL,
  55. artist text,
  56. title text,
  57. spotify_url text,
  58. synced boolean NOT NULL DEFAULT false,
  59. CONSTRAINT entry_pkey PRIMARY KEY (user_id, round_id)
  60. );
  61. -- Table: public.round_playlist
  62. -- DROP TABLE public.round_playlist;
  63. CREATE TABLE public.round_playlist
  64. (
  65. round_id int,
  66. tracks text[],
  67. CONSTRAINT round_id FOREIGN KEY (round_id)
  68. REFERENCES public.round (id)
  69. );