Add DB table for song history
This commit is contained in:
parent
7bcb5f8c04
commit
81f0b9310f
2
migrations/2024-05-19-163229_add_song_history/down.sql
Normal file
2
migrations/2024-05-19-163229_add_song_history/down.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
DROP INDEX song_history_user_id_idx;
|
||||||
|
DROP TABLE song_history;
|
8
migrations/2024-05-19-163229_add_song_history/up.sql
Normal file
8
migrations/2024-05-19-163229_add_song_history/up.sql
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
CREATE TABLE song_history (
|
||||||
|
id SERIAL PRIMARY KEY UNIQUE NOT NULL,
|
||||||
|
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||||
|
date TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
song_id INTEGER REFERENCES songs(id) ON DELETE CASCADE NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX song_history_user_id_idx ON song_history(user_id);
|
@ -30,6 +30,15 @@ diesel::table! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
song_history (id) {
|
||||||
|
id -> Int4,
|
||||||
|
user_id -> Int4,
|
||||||
|
date -> Timestamp,
|
||||||
|
song_id -> Int4,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
songs (id) {
|
songs (id) {
|
||||||
id -> Int4,
|
id -> Int4,
|
||||||
@ -57,6 +66,8 @@ diesel::joinable!(album_artists -> albums (album_id));
|
|||||||
diesel::joinable!(album_artists -> artists (artist_id));
|
diesel::joinable!(album_artists -> artists (artist_id));
|
||||||
diesel::joinable!(song_artists -> artists (artist_id));
|
diesel::joinable!(song_artists -> artists (artist_id));
|
||||||
diesel::joinable!(song_artists -> songs (song_id));
|
diesel::joinable!(song_artists -> songs (song_id));
|
||||||
|
diesel::joinable!(song_history -> songs (song_id));
|
||||||
|
diesel::joinable!(song_history -> users (user_id));
|
||||||
diesel::joinable!(songs -> albums (album_id));
|
diesel::joinable!(songs -> albums (album_id));
|
||||||
|
|
||||||
diesel::allow_tables_to_appear_in_same_query!(
|
diesel::allow_tables_to_appear_in_same_query!(
|
||||||
@ -64,6 +75,7 @@ diesel::allow_tables_to_appear_in_same_query!(
|
|||||||
albums,
|
albums,
|
||||||
artists,
|
artists,
|
||||||
song_artists,
|
song_artists,
|
||||||
|
song_history,
|
||||||
songs,
|
songs,
|
||||||
users,
|
users,
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user