Skip to content

Commit

Permalink
Lock tables during pkey index migration (#6063)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacsolo committed Sep 20, 2023
1 parent 4a66c18 commit b41e8c2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions discovery-provider/ddl/migrations/0031_drop_current_indices.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
-- Drop is_current from any primary keys or indices with is_current
-- Improves performance and storage utilization
BEGIN;
SELECT pg_cancel_backend(pid) FROM pg_stat_activity WHERE state = 'active' and pid <> pg_backend_pid();

LOCK TABLE grants IN ACCESS EXCLUSIVE MODE;
LOCK TABLE users IN ACCESS EXCLUSIVE MODE;
LOCK TABLE playlist_seen IN ACCESS EXCLUSIVE MODE;
LOCK TABLE subscriptions IN ACCESS EXCLUSIVE MODE;
LOCK TABLE tracks IN ACCESS EXCLUSIVE MODE;
LOCK TABLE follows IN ACCESS EXCLUSIVE MODE;
LOCK TABLE saves IN ACCESS EXCLUSIVE MODE;
LOCK TABLE developer_apps IN ACCESS EXCLUSIVE MODE;
LOCK TABLE playlists IN ACCESS EXCLUSIVE MODE;
LOCK TABLE user_events IN ACCESS EXCLUSIVE MODE;
LOCK TABLE associated_wallets IN ACCESS EXCLUSIVE MODE;
LOCK TABLE playlist_routes IN ACCESS EXCLUSIVE MODE;

DO $$
DECLARE
Expand Down

0 comments on commit b41e8c2

Please sign in to comment.