Skip to content

Commit

Permalink
fix: too many loops while running migrations (#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag authored Dec 18, 2024
1 parent 4a5d23d commit faf326e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ do $$

perform pg_notify('migrations-{{ .Schema }}', 'init: ' || _count);

for i in 0.._count by _batch_size loop
for i in 0.._count-1 by _batch_size loop
-- disable triggers
set session_replication_role = replica;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ do $$
) moves
group by transactions_id;

perform pg_notify('migrations-{{ .Schema }}', 'init: ' || (select count(*) from moves_view));

create index moves_view_idx on moves_view(transactions_id);

if (select count(*) from moves_view) = 0 then
return;
end if;

perform pg_notify('migrations-{{ .Schema }}', 'init: ' || (select count(*) from moves_view));

-- disable triggers
set session_replication_role = replica;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ do $$

raise info '_count: %', _count;

for i in 0.._count by _batch_size loop
for i in 0.._count-1 by _batch_size loop
with _rows as (
select *
from tmp_volumes
Expand Down

0 comments on commit faf326e

Please sign in to comment.