fix(procore): harden audit migration delete guard#27
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 398a83025f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| perform set_config('app.procore_audit_delete_allowed', 'on', true); | ||
| delete from private.procore_audit | ||
| where created_at < now() - (retention_days || ' days')::interval; | ||
| perform set_config('app.procore_audit_delete_allowed', 'off', true); |
There was a problem hiding this comment.
Capture row count before clearing the guard
When this purge deletes any number of audit rows, the new perform set_config(..., 'off', true) becomes the most recent SQL statement before GET DIAGNOSTICS v_deleted = row_count, so the function reports the row count from set_config instead of the DELETE. This makes the RPC return an incorrect deletion count (and the same ordering appears in delete_procore_audit_for_company below); store row_count immediately after the DELETE, then clear the guard.
Useful? React with 👍 / 👎.
private.prevent_procore_audit_mutation()with an explicit emptysearch_path.Tests:
python -m pytest tests/test_procore_audit_migration.py-> 7 passedflake8 tests/test_procore_audit_migration.py-> cleanNo app code touched. Migration not applied.