Skip to content

Commit 012ed81

Browse files
fix: playlists videos removal for PostgreSQL (#835)
* Fix playlists videos removal for PostgreSQL Fixes the constraint violation error upon removing a video from a playlist with PostgreSQL Resolves TeamPiped/Piped#2814 * Replace comment * Show responses for the requests in api-test.sh * Revert "Show responses for the requests in api-test.sh" This reverts commit 29f6447.
1 parent 6e6705f commit 012ed81

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/main/resources/changelog/db.changelog-master.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66

77
<include file="version/0-init.xml" relativeToChangelogFile="true"/>
88
<include file="version/1-fix-subs.xml" relativeToChangelogFile="true"/>
9+
<include file="version/2-fix-playlist-reordering-in-postgresql.xml" relativeToChangelogFile="true"/>
910
</databaseChangeLog>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
5+
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
6+
7+
<changeSet id="2-0-postgresql" author="valentins.paramonovs" dbms="postgresql">
8+
<!-- delay constraint checks until the end of the transaction to allow videos in a playlist to be reordered without worrying about the update execution order -->
9+
<sql>ALTER TABLE playlists_videos_ids DROP CONSTRAINT playlists_videos_ids_pkey;</sql>
10+
<sql>ALTER TABLE playlists_videos_ids ADD CONSTRAINT playlists_videos_ids_pkey PRIMARY KEY (playlist_id, videos_order) DEFERRABLE INITIALLY DEFERRED;</sql>
11+
<rollback>
12+
<sql>ALTER TABLE playlists_videos_ids DROP CONSTRAINT playlists_videos_ids_pkey;</sql>
13+
<sql>ALTER TABLE playlists_videos_ids ADD CONSTRAINT playlists_videos_ids_pkey PRIMARY KEY (playlist_id, videos_order);</sql>
14+
</rollback>
15+
</changeSet>
16+
17+
</databaseChangeLog>

0 commit comments

Comments
 (0)