Skip to content

Commit

Permalink
Disable triggers while migration runs (#7001)
Browse files Browse the repository at this point in the history
  • Loading branch information
theoilie authored Dec 20, 2023
1 parent a542274 commit 97e8ae3
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
begin;

alter table tracks disable trigger on_track;
alter table tracks disable trigger trg_tracks;

SELECT pg_cancel_backend(pid) FROM pg_stat_activity WHERE state = 'active' and pid <> pg_backend_pid();
lock table tracks in access exclusive mode;

UPDATE tracks
SET release_date = created_at
WHERE release_date IS NULL;

alter table tracks enable trigger on_track;
alter table tracks enable trigger trg_tracks;

commit;

0 comments on commit 97e8ae3

Please sign in to comment.