Files
lincodex/backend/db/migrations/00042_index_contact_grants_by_candidate.sql

13 lines
569 B
SQL

-- +goose Up
-- A visibility change of the whole profile closes every active grant of one
-- candidate: the revocation of C2 and the closing of the publication. The
-- existing active index leads with the organization, so it cannot serve that
-- lookup. The index holds no data and only speeds up the closing statement.
CREATE INDEX contact_grants_candidate_active_idx
ON contact_grants (candidate_id)
WHERE revoked_at IS NULL;
-- +goose Down
-- The index holds no data, so a rollback drops only the lookup it provides.
DROP INDEX contact_grants_candidate_active_idx;