bourb0n

Untitled

Jan 19th, 2021
1,339
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create table users (
  2.   id character(32) not null,
  3.   user_name character varying(32) not null,
  4.   email character varying(128),
  5.   password character(98) not null, -- The App's bcrypt hash length
  6.   internal boolean not null,
  7.   api_key character varying(128),
  8.   modified_user_id character(32),
  9.   modified_date timestamp without time zone not null
  10. );
  11. alter table only users add constraint pk_users_idx primary key (id);
  12. alter table only users add constraint uk_users_1_idx unique (user_name);
  13. alter table only users add constraint uk_users_2_idx unique (api_key);
  14. create index fk_users_1_idx on users using btree (modified_user_id);
  15. alter table only users add constraint fk_users_1 foreign key (modified_user_id) references users(id) on delete cascade deferrable;
  16.  
  17. create table movie (
  18.   id character(32) not null,
  19.   name character varying(512) not null,
  20.   year integer,
  21.   imdb_tconst character(16),
  22.   modified_user_id character(32),
  23.   modified_date timestamp without time zone not null
  24. );
  25. alter table only movie add constraint pk_movie_idx primary key (id);
  26. alter table only movie add constraint uk_movie_1_idx unique (name);
  27. create index fk_movie_1_idx on movie using btree (modified_user_id);
  28. alter table only movie add constraint fk_movie_1 foreign key (modified_user_id) references users(id) on delete cascade deferrable;
  29.  
  30. create table tv (
  31.   id character(32) not null,
  32.   name character varying(512) not null,
  33.   year integer,
  34.   imdb_tconst character(16),
  35.   modified_user_id character(32),
  36.   modified_date timestamp without time zone not null
  37. );
  38. alter table only tv add constraint pk_tv_idx primary key (id);
  39. alter table only tv add constraint uk_tv_1_idx unique (name);
  40. create index fk_tv_1_idx on tv using btree (modified_user_id);
  41. alter table only tv add constraint fk_tv_1 foreign key (modified_user_id) references users(id) on delete cascade deferrable;
  42.  
  43. create table movie_data (
  44.   id character(32) not null,
  45.   movie_id character(32) not null,
  46.   tmdb_id character varying(32),
  47.   tmdb_poster_path character varying(512),
  48.   overview character varying(1028),
  49.   rating_id numeric(2, 0),
  50.   imdb_score double precision,
  51.   rotten_tomatoes_score character varying(16),
  52.   metacritic_score integer,
  53.   language character varying(64),
  54.   runtime integer,
  55.   modified_user_id character(32),
  56.   modified_date timestamp without time zone not null
  57. );
  58. alter table only movie_data add constraint pk_movie_data_idx primary key (id);
  59. alter table only movie_data add constraint uk_movie_data_1_idx unique (movie_id);
  60. create index fk_movie_data_1_idx on movie_data using btree (modified_user_id);
  61. alter table only movie_data add constraint fk_movie_data_1 foreign key (rating_id) references rating(id) on delete cascade deferrable;
  62. alter table only movie_data add constraint fk_movie_data_2 foreign key (modified_user_id) references users(id) on delete cascade deferrable;
  63.  
  64. create table tv_data (
  65.   id character(32) not null,
  66.   tv_id character(32) not null,
  67.   rating_id numeric(2, 0),
  68.   imdb_score double precision,
  69.   rotten_tomatoes_score character varying(16),
  70.   metacritic_score integer,
  71.   language character varying(64),
  72.   modified_user_id character(32),
  73.   modified_date timestamp without time zone not null
  74. );
  75. alter table only tv_data add constraint pk_tv_data_idx primary key (id);
  76. alter table only tv_data add constraint uk_tv_data_1_idx unique (tv_id);
  77. create index fk_tv_data_1_idx on tv_data using btree (modified_user_id);
  78. alter table only tv_data add constraint fk_tv_data_1 foreign key (rating_id) references rating(id) on delete cascade deferrable;
  79. alter table only tv_data add constraint fk_tv_data_2 foreign key (modified_user_id) references users(id) on delete cascade deferrable;
RAW Paste Data