From b6636841d4ebeade2b21b54d3cb9fc68b16d7b30 Mon Sep 17 00:00:00 2001 From: gaikwadsid Date: Thu, 19 Sep 2024 18:38:06 -0400 Subject: [PATCH 1/4] Added rest of schema --- .../migrations/20240917002108_base_schema.sql | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/backend/internal/supabase/migrations/20240917002108_base_schema.sql b/backend/internal/supabase/migrations/20240917002108_base_schema.sql index a2e5b279..7b1f8220 100644 --- a/backend/internal/supabase/migrations/20240917002108_base_schema.sql +++ b/backend/internal/supabase/migrations/20240917002108_base_schema.sql @@ -60,4 +60,38 @@ create table if not exists review ( comment text, created_at timestamp with time zone default now(), updated_at timestamp with time zone default now() +); + +create table if not exists follower ( + follower_id uuid not null references "user"(id), + followee_id uuid not null references "user"(id), + primary key (follower_id, followee_id) +); + +create table if not exists playlist ( + id serial primary key, + title text not null, + user_id uuid not null references "user"(id), + bio text, + cover_photo text +); + +create table if not exists playlist_track ( + playlist_id bigint not null references playlist(id), + track_id bigint not null references track(id), + primary key (playlist_id, track_id) +); + +create table if not exists user_auth ( + id serial primary key, + user_id uuid not null references "user"(id), + refresh_token text not null, + access_token text not null, +) + +create table if not exists user_review_vote ( + user_id uuid not null references "user"(id), + review_id integer not null references review(id), + vote boolean not null, + primary key (user_id, review_id) ); \ No newline at end of file From cefc909e2ce9fb002f140b837bf5b1ac0bd37527 Mon Sep 17 00:00:00 2001 From: gaikwadsid Date: Fri, 20 Sep 2024 22:17:35 -0400 Subject: [PATCH 2/4] Added data into the tables --- .../migrations/20240917002108_base_schema.sql | 2 +- backend/internal/supabase/seed.sql | 38 ++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/backend/internal/supabase/migrations/20240917002108_base_schema.sql b/backend/internal/supabase/migrations/20240917002108_base_schema.sql index 7b1f8220..e3332742 100644 --- a/backend/internal/supabase/migrations/20240917002108_base_schema.sql +++ b/backend/internal/supabase/migrations/20240917002108_base_schema.sql @@ -69,7 +69,7 @@ create table if not exists follower ( ); create table if not exists playlist ( - id serial primary key, + playlist_id serial primary key, title text not null, user_id uuid not null references "user"(id), bio text, diff --git a/backend/internal/supabase/seed.sql b/backend/internal/supabase/seed.sql index 4e137f3f..3dc91279 100644 --- a/backend/internal/supabase/seed.sql +++ b/backend/internal/supabase/seed.sql @@ -52,4 +52,40 @@ VALUES ('2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e', 2, 'album', 4, 'I like this album.'), ('3c4d5e6f-7a8b-9c0d-1e2f-3a4b5c6d7e8f', 1, 'track', 3, 'This song is okay.'), ('4d5e6f7a-8b9c-0d1e-2f3a-4b5c6d7e8f9d', 3, 'track', 2, 'I don''t like this song.'), - ('4d5e6f7a-8b9c-0d1e-2f3a-4b5c6d7e8f9d', 5, 'track', 2, 'This song is the best song ever'); \ No newline at end of file + ('4d5e6f7a-8b9c-0d1e-2f3a-4b5c6d7e8f9d', 5, 'track', 2, 'This song is the best song ever'); + +INSERT INTO follower (follower_id, followee_id) +VALUES + ('1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d', '2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e'), + ('2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e', '1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d'), + ('3c4d5e6f-7a8b-9c0d-1e2f-3a4b5c6d7e8f', '1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d'); + +INSERT INTO playlist (playlist_id, title, user_id, bio, cover_photo) +VALUES + (1, '2024', '1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d', 'Playlist for 2024', 'https://upload.wikimedia.org/wikipedia/commons/0/0a/Nils_B%C3%A4ckstr%C3%B6m_Rubin_Tyumen.jpg'), + (2, 'Movie Music', '1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d', 'Cinematic soundtracks and epic scores that bring the magic of movies to life.', 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/Anolis_marmoratus%28fight%29.jpg/1280px-Anolis_marmoratus%28fight%29.jpg'), + (3, 'Chill Vibes', '2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e', 'High-energy tracks to power your workout sessions.', 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f5/FOS244.jpg/1280px-FOS244.jpg'), + (4, 'Workout Mix', '3c4d5e6f-7a8b-9c0d-1e2f-3a4b5c6d7e8f', 'A collection of nostalgic hits from past decades.', 'https://upload.wikimedia.org/wikipedia/commons/b/be/High_Airmass_Spectra_%28AuxTel-Feb%29.jpg'), + (5, 'Platnm', '5e6f7a8b-9c0d-1e2f-3a4b-5c6d7e8f9d0e', 'Playlist for the Platnm Team', 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/d0/BCJMPort2017.jpg/1920px-BCJMPort2017.jpg'); + +INSERT INTO playlist_track (playlist_id, track_id) +VALUES + (1, 1), + (2, 2), + (3, 3); + +INSERT INTO user_auth (id, user_id, refresh_token, access_token) +VALUES + (1, '1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d', 'refresh_token_abc123', 'access_token_xyz123'), + (2, '2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e', 'refresh_token_def456', 'access_token_uvw456'), + (3, '3c4d5e6f-7a8b-9c0d-1e2f-3a4b5c6d7e8f', 'refresh_token_ghi789', 'access_token_rst789'), + (4, '4d5e6f7a-8b9c-0d1e-2f3a-4b5c6d7e8f9d', 'refresh_token_jkl012', 'access_token_opq012'), + (5, '5e6f7a8b-9c0d-1e2f-3a4b-5c6d7e8f9d0e', 'refresh_token_mno345', 'access_token_lmn345'); + +INSERT INTO user_review_vote (user_id, review_id, vote) +VALUES + ('1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d', 1, 1), + ('2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e', 2, 1), + ('3c4d5e6f-7a8b-9c0d-1e2f-3a4b5c6d7e8f', 3, -1), + ('4d5e6f7a-8b9c-0d1e-2f3a-4b5c6d7e8f9d', 4, -1), + ('5e6f7a8b-9c0d-1e2f-3a4b-5c6d7e8f9d0e', 5, 1); \ No newline at end of file From 551b292f411258b2d90cd7e538e7d455210e4775 Mon Sep 17 00:00:00 2001 From: gaikwadsid Date: Sat, 21 Sep 2024 21:49:17 -0400 Subject: [PATCH 3/4] Fixed syntax errrors --- .../supabase/migrations/20240917002108_base_schema.sql | 8 ++++---- backend/internal/supabase/seed.sql | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/internal/supabase/migrations/20240917002108_base_schema.sql b/backend/internal/supabase/migrations/20240917002108_base_schema.sql index e3332742..6b002f79 100644 --- a/backend/internal/supabase/migrations/20240917002108_base_schema.sql +++ b/backend/internal/supabase/migrations/20240917002108_base_schema.sql @@ -69,7 +69,7 @@ create table if not exists follower ( ); create table if not exists playlist ( - playlist_id serial primary key, + id serial primary key, title text not null, user_id uuid not null references "user"(id), bio text, @@ -86,12 +86,12 @@ create table if not exists user_auth ( id serial primary key, user_id uuid not null references "user"(id), refresh_token text not null, - access_token text not null, -) + access_token text not null +); create table if not exists user_review_vote ( user_id uuid not null references "user"(id), review_id integer not null references review(id), - vote boolean not null, + upvote boolean not null, primary key (user_id, review_id) ); \ No newline at end of file diff --git a/backend/internal/supabase/seed.sql b/backend/internal/supabase/seed.sql index 3dc91279..bcd134ea 100644 --- a/backend/internal/supabase/seed.sql +++ b/backend/internal/supabase/seed.sql @@ -84,8 +84,8 @@ VALUES INSERT INTO user_review_vote (user_id, review_id, vote) VALUES - ('1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d', 1, 1), - ('2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e', 2, 1), - ('3c4d5e6f-7a8b-9c0d-1e2f-3a4b5c6d7e8f', 3, -1), - ('4d5e6f7a-8b9c-0d1e-2f3a-4b5c6d7e8f9d', 4, -1), - ('5e6f7a8b-9c0d-1e2f-3a4b-5c6d7e8f9d0e', 5, 1); \ No newline at end of file + ('1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d', 1, true), + ('2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e', 2, false), + ('3c4d5e6f-7a8b-9c0d-1e2f-3a4b5c6d7e8f', 3, false), + ('4d5e6f7a-8b9c-0d1e-2f3a-4b5c6d7e8f9d', 4, false), + ('5e6f7a8b-9c0d-1e2f-3a4b-5c6d7e8f9d0e', 5, true); \ No newline at end of file From 22b4ed7932899576c2aabe3e759a99f4dca18868 Mon Sep 17 00:00:00 2001 From: gaikwadsid Date: Sun, 22 Sep 2024 18:57:24 -0400 Subject: [PATCH 4/4] Example for new script --- .../migrations/20240917002108_base_schema.sql | 34 ------------------- .../20240922222648_add_rest_of_schema.sql | 33 ++++++++++++++++++ backend/internal/supabase/seed.sql | 4 +-- 3 files changed, 35 insertions(+), 36 deletions(-) create mode 100644 backend/internal/supabase/migrations/20240922222648_add_rest_of_schema.sql diff --git a/backend/internal/supabase/migrations/20240917002108_base_schema.sql b/backend/internal/supabase/migrations/20240917002108_base_schema.sql index 6b002f79..a2e5b279 100644 --- a/backend/internal/supabase/migrations/20240917002108_base_schema.sql +++ b/backend/internal/supabase/migrations/20240917002108_base_schema.sql @@ -60,38 +60,4 @@ create table if not exists review ( comment text, created_at timestamp with time zone default now(), updated_at timestamp with time zone default now() -); - -create table if not exists follower ( - follower_id uuid not null references "user"(id), - followee_id uuid not null references "user"(id), - primary key (follower_id, followee_id) -); - -create table if not exists playlist ( - id serial primary key, - title text not null, - user_id uuid not null references "user"(id), - bio text, - cover_photo text -); - -create table if not exists playlist_track ( - playlist_id bigint not null references playlist(id), - track_id bigint not null references track(id), - primary key (playlist_id, track_id) -); - -create table if not exists user_auth ( - id serial primary key, - user_id uuid not null references "user"(id), - refresh_token text not null, - access_token text not null -); - -create table if not exists user_review_vote ( - user_id uuid not null references "user"(id), - review_id integer not null references review(id), - upvote boolean not null, - primary key (user_id, review_id) ); \ No newline at end of file diff --git a/backend/internal/supabase/migrations/20240922222648_add_rest_of_schema.sql b/backend/internal/supabase/migrations/20240922222648_add_rest_of_schema.sql new file mode 100644 index 00000000..ee517ddb --- /dev/null +++ b/backend/internal/supabase/migrations/20240922222648_add_rest_of_schema.sql @@ -0,0 +1,33 @@ +create table if not exists follower ( + follower_id uuid not null references "user"(id), + followee_id uuid not null references "user"(id), + primary key (follower_id, followee_id) +); + +create table if not exists playlist ( + id serial primary key, + title text not null, + user_id uuid not null references "user"(id), + bio text, + cover_photo text +); + +create table if not exists playlist_track ( + playlist_id bigint not null references playlist(id), + track_id bigint not null references track(id), + primary key (playlist_id, track_id) +); + +create table if not exists user_auth ( + id serial primary key, + user_id uuid not null references "user"(id), + refresh_token text not null, + access_token text not null +); + +create table if not exists user_review_vote ( + user_id uuid not null references "user"(id), + review_id integer not null references review(id), + upvote boolean not null, + primary key (user_id, review_id) +); \ No newline at end of file diff --git a/backend/internal/supabase/seed.sql b/backend/internal/supabase/seed.sql index bcd134ea..c37e7d05 100644 --- a/backend/internal/supabase/seed.sql +++ b/backend/internal/supabase/seed.sql @@ -60,7 +60,7 @@ VALUES ('2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e', '1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d'), ('3c4d5e6f-7a8b-9c0d-1e2f-3a4b5c6d7e8f', '1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d'); -INSERT INTO playlist (playlist_id, title, user_id, bio, cover_photo) +INSERT INTO playlist (id, title, user_id, bio, cover_photo) VALUES (1, '2024', '1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d', 'Playlist for 2024', 'https://upload.wikimedia.org/wikipedia/commons/0/0a/Nils_B%C3%A4ckstr%C3%B6m_Rubin_Tyumen.jpg'), (2, 'Movie Music', '1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d', 'Cinematic soundtracks and epic scores that bring the magic of movies to life.', 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/Anolis_marmoratus%28fight%29.jpg/1280px-Anolis_marmoratus%28fight%29.jpg'), @@ -82,7 +82,7 @@ VALUES (4, '4d5e6f7a-8b9c-0d1e-2f3a-4b5c6d7e8f9d', 'refresh_token_jkl012', 'access_token_opq012'), (5, '5e6f7a8b-9c0d-1e2f-3a4b-5c6d7e8f9d0e', 'refresh_token_mno345', 'access_token_lmn345'); -INSERT INTO user_review_vote (user_id, review_id, vote) +INSERT INTO user_review_vote (user_id, review_id, upvote) VALUES ('1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d', 1, true), ('2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e', 2, false),