-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
… to tracks (#7708) Co-authored-by: Dharit Tantiviramanond <dharit.tan@gmail.com>
- Loading branch information
1 parent
f25cc23
commit 4136985
Showing
6 changed files
with
272 additions
and
6 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
packages/discovery-provider/ddl/migrations/0056_playlists_containing_track.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,18 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE tracks | ||
ADD column IF NOT EXISTS playlists_containing_track INTEGER[] NOT NULL DEFAULT '{}'; | ||
|
||
UPDATE tracks SET playlists_containing_track = subquery.playlists_containing_track FROM ( | ||
SELECT | ||
CAST(jsonb_array_elements(playlist_contents->'track_ids')->>'track' AS INTEGER) AS track_id, | ||
ARRAY_AGG(playlist_id) AS playlists_containing_track | ||
FROM playlists | ||
WHERE playlist_id IS NOT NULL | ||
GROUP BY track_id | ||
) AS subquery | ||
WHERE tracks.track_id = subquery.track_id | ||
AND subquery.track_id IS NOT NULL | ||
AND tracks.track_id IS NOT NULL; | ||
|
||
COMMIT; |
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
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,4 @@ | ||
black . | ||
flake8 . | ||
mypy . | ||
isort . |
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