CREATE INDEX IF NOT EXISTS idx_module_doh_profile_id
    ON module (doh_profile_id) WHERE deleted_at IS NULL AND doh_profile_id IS NOT NULL;

CREATE INDEX IF NOT EXISTS idx_module_default_community
    ON module (default_community_id) WHERE deleted_at IS NULL AND default_community_id IS NOT NULL;

CREATE INDEX IF NOT EXISTS idx_bgp_speaker_last_applied
    ON bgp_speaker (last_applied_revision_id) WHERE last_applied_revision_id IS NOT NULL;

CREATE INDEX IF NOT EXISTS idx_bgp_speaker_published
    ON bgp_speaker (published_revision_id) WHERE published_revision_id IS NOT NULL;

CREATE INDEX IF NOT EXISTS idx_config_revision_tenant_module_created
    ON config_revision (tenant_id, module_id, created_at DESC);

CREATE INDEX IF NOT EXISTS idx_rev_mat_prefix_rev_id
    ON revision_materialized_prefix (revision_id, id);
