All rules Rule BV021
warning
hosted, paid — --remote

Materialized view refreshed without CONCURRENTLY

Warning — this works, but blocks traffic or rewrites data at scale.

What it catches

A plain REFRESH MATERIALIZED VIEW takes an exclusive lock on the view while it recomputes — every SELECT against it blocks for the whole rebuild. REFRESH ... CONCURRENTLY lets readers keep the old contents during the rebuild; it requires a unique index on the view.

Fires on

REFRESH MATERIALIZED VIEW daily_revenue;

Do this instead

REFRESH MATERIALIZED VIEW CONCURRENTLY lets readers keep the old contents while the new version is computed and diffed in. It requires a unique index on the view — build one CONCURRENTLY first if it is missing.

-- one-time prerequisite, own migration outside a transaction:
--    CREATE UNIQUE INDEX CONCURRENTLY daily_revenue_day_idx
--      ON daily_revenue (day);
REFRESH MATERIALIZED VIEW CONCURRENTLY daily_revenue;
Catch this before it ships

This rule runs in the hosted service on Startup and above — add --remote with a team token, or use the GitHub Action: npx bolvrk check migration.sql