Skip to content

fix(procore): harden audit migration delete guard#27

Merged
mcxl merged 1 commit into
mainfrom
codex/procore-migration-008-hardening
Jun 17, 2026
Merged

fix(procore): harden audit migration delete guard#27
mcxl merged 1 commit into
mainfrom
codex/procore-migration-008-hardening

Conversation

@mcxl

@mcxl mcxl commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Tests:

  • python -m pytest tests/test_procore_audit_migration.py -> 7 passed
  • flake8 tests/test_procore_audit_migration.py -> clean
  • pre-push full suite -> passed

No app code touched. Migration not applied.

@mcxl mcxl merged commit a77d9f5 into main Jun 17, 2026
1 check passed
@mcxl mcxl deleted the codex/procore-migration-008-hardening branch June 17, 2026 22:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant