-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from go-park-mail-ru/NM-95
Nm 95
- Loading branch information
Showing
40 changed files
with
2,886 additions
and
5 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
internal/db/postgres/migrations/20241213224512_create_favorite_artist.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
-- +goose Up | ||
-- +goose StatementBegin | ||
CREATE TABLE IF NOT EXISTS "favorite_artist" ( | ||
id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY, | ||
user_id UUID REFERENCES "user" (id) ON DELETE CASCADE, | ||
artist_id INT NOT NULL REFERENCES "artist" (id) ON DELETE CASCADE, | ||
created_at TIMESTAMPTZ DEFAULT NOW(), | ||
updated_at TIMESTAMPTZ DEFAULT NOW() | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS "favorite_album" ( | ||
id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY, | ||
user_id UUID REFERENCES "user" (id) ON DELETE CASCADE, | ||
album_id INT NOT NULL REFERENCES "album" (id) ON DELETE CASCADE, | ||
created_at TIMESTAMPTZ DEFAULT NOW(), | ||
updated_at TIMESTAMPTZ DEFAULT NOW() | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS "favorite_playlist" ( | ||
id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY, | ||
user_id UUID REFERENCES "user" (id) ON DELETE CASCADE, | ||
playlist_id INT NOT NULL REFERENCES "playlist" (id) ON DELETE CASCADE, | ||
created_at TIMESTAMPTZ DEFAULT NOW(), | ||
updated_at TIMESTAMPTZ DEFAULT NOW() | ||
); | ||
|
||
CREATE UNIQUE INDEX favorite_artist_unique ON favorite_artist (user_id, artist_id); | ||
CREATE UNIQUE INDEX favorite_album_unique ON favorite_album (user_id, album_id); | ||
CREATE UNIQUE INDEX favorite_playlist_unique ON favorite_playlist (user_id, playlist_id); | ||
-- +goose StatementEnd | ||
|
||
-- +goose Down | ||
-- +goose StatementBegin | ||
DROP TABLE IF EXISTS "favorite_playlist" CASCADE; | ||
DROP TABLE IF EXISTS "favorite_album" CASCADE; | ||
DROP TABLE IF EXISTS "favorite_artist" CASCADE; | ||
-- +goose StatementEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.