Merge pull request 'Implement friends' (#96) from 44-implement-friends into main
Reviewed-on: LibreTunes/LibreTunes#96
This commit is contained in:
commit
236c75492a
7
migrations/2024-05-20-154208_add_friends/down.sql
Normal file
7
migrations/2024-05-20-154208_add_friends/down.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
DROP INDEX friendships_friend_2_idx;
|
||||||
|
DROP INDEX friendships_friend_1_idx;
|
||||||
|
DROP TABLE friendships;
|
||||||
|
|
||||||
|
DROP INDEX incoming_friend_requests_idx;
|
||||||
|
DROP INDEX outgoing_friend_requests_idx;
|
||||||
|
DROP TABLE friend_requests;
|
19
migrations/2024-05-20-154208_add_friends/up.sql
Normal file
19
migrations/2024-05-20-154208_add_friends/up.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
CREATE TABLE friend_requests (
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
from_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||||
|
to_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||||
|
PRIMARY KEY (from_id, to_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX outgoing_friend_requests_idx ON friend_requests(from_id);
|
||||||
|
CREATE INDEX incoming_friend_requests_idx ON friend_requests(to_id);
|
||||||
|
|
||||||
|
CREATE TABLE friendships (
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
friend_1_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||||
|
friend_2_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||||
|
PRIMARY KEY (friend_1_id, friend_2_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX friendships_friend_1_idx ON friendships(friend_1_id);
|
||||||
|
CREATE INDEX friendships_friend_2_idx ON friendships(friend_2_id);
|
@ -23,6 +23,22 @@ diesel::table! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
friend_requests (from_id, to_id) {
|
||||||
|
created_at -> Timestamp,
|
||||||
|
from_id -> Int4,
|
||||||
|
to_id -> Int4,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
friendships (friend_1_id, friend_2_id) {
|
||||||
|
created_at -> Timestamp,
|
||||||
|
friend_1_id -> Int4,
|
||||||
|
friend_2_id -> Int4,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
song_artists (song_id, artist_id) {
|
song_artists (song_id, artist_id) {
|
||||||
song_id -> Int4,
|
song_id -> Int4,
|
||||||
@ -82,6 +98,8 @@ diesel::allow_tables_to_appear_in_same_query!(
|
|||||||
album_artists,
|
album_artists,
|
||||||
albums,
|
albums,
|
||||||
artists,
|
artists,
|
||||||
|
friend_requests,
|
||||||
|
friendships,
|
||||||
song_artists,
|
song_artists,
|
||||||
song_dislikes,
|
song_dislikes,
|
||||||
song_likes,
|
song_likes,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user