Skip to main content

max / makenotwork

661 B · 14 lines History Blame Raw
1 -- Fix download_fingerprints and streaming_sessions FK constraints to cascade on user deletion.
2 -- Previously these used the default ON DELETE RESTRICT, which blocked account deletion
3 -- for any user who had downloaded or streamed content.
4
5 ALTER TABLE download_fingerprints
6 DROP CONSTRAINT download_fingerprints_user_id_fkey,
7 ADD CONSTRAINT download_fingerprints_user_id_fkey
8 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
9
10 ALTER TABLE streaming_sessions
11 DROP CONSTRAINT streaming_sessions_user_id_fkey,
12 ADD CONSTRAINT streaming_sessions_user_id_fkey
13 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
14