Skip to content

ENG-3386: schema for regulatory reporting templates#7999

Draft
adamsachs wants to merge 1 commit intomainfrom
ENG-3386-custom-field-system-managed
Draft

ENG-3386: schema for regulatory reporting templates#7999
adamsachs wants to merge 1 commit intomainfrom
ENG-3386-custom-field-system-managed

Conversation

@adamsachs
Copy link
Copy Markdown
Contributor

Ticket ENG-3386

Companion PRs: fidesplus#3407 (backend reconciler — depends on this PR) and fides#7910 (FE popover). Merge this PR first.

Description Of Changes

Schema-only PR that adds the columns and association table needed to support the location-gated regulatory reporting templates feature implemented in fidesplus#3407. The business logic (reconciler, location-change hook, route guards) lives in fidesplus; this PR only extends the shared data model.

Code Changes

Model (src/fides/api/models/)

  • sql_models.py:CustomFieldDefinition — adds system_managed: bool (NOT NULL, default False). Marks field definitions whose lifecycle is controlled by a platform flow (the fidesplus reporting-templates reconciler). User-created fields default to False and are untouched by that flow.
  • custom_report.py:CustomReport — adds system_template_key: Optional[str] and location_code: Optional[str], both indexed, both NULL for user-created reports. The reconciler populates them for the system-owned ICO/DPC/CNIL templates.
  • custom_report.py:reporting_template_custom_field — new M:N association table between CustomReport and CustomFieldDefinition, cascade-delete on both sides. Exposed on the ORM via CustomReport.custom_field_definitions. Used by the reconciler to track "which gap fields does this template reference" and to drive the orphan-deactivation pass when a location is deselected.

Migration

  • xx_2026_04_22_1600_c8e9d3f7a2b4_reporting_templates_schema.py — revises d71c7d274c04 (current head on main). Adds the three columns, the two indexes, and the association table. downgrade() is a clean reverse.

Tests

  • tests/ctl/core/test_custom_field_models.py — two tests: system_managed defaults to False, system_managed is settable to True via the creation API. The broader semantics (lifecycle, reconciliation) are covered in fidesplus.

Steps to Confirm

  1. Run the unit tests:

    nox -s pytest -- tests/ctl/core/test_custom_field_models.py -v

    Expected: existing tests + two new system_managed tests pass.

  2. Apply migrations against a fresh DB and confirm schema:

    docker exec <db-container> psql -U postgres -d fides -c "\d plus_custom_field_definition" | grep system_managed
    docker exec <db-container> psql -U postgres -d fides -c "\d plus_custom_report" | grep -E "system_template_key|location_code"
    docker exec <db-container> psql -U postgres -d fides -c "\d plus_reporting_template_custom_field"

    Expected: system_managed boolean NOT NULL DEFAULT false, both new CustomReport columns (nullable, indexed), association table with composite PK + CASCADE FKs.

  3. Confirm alembic heads returns a single head after upgrade:

    alembic heads

    Expected: c8e9d3f7a2b4 (head).

Pre-Merge Checklist

  • All CI Pipelines Succeeded
  • Documentation:
    • No documentation updates required (feature docs tracked in fidesplus#3407)
    • No new client scopes
  • No new high-risk changes
  • Update CHANGELOG.md — changelog fragment added at changelog/system-managed-custom-field-definition.yaml

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
fides-plus-nightly Ignored Ignored Preview Apr 22, 2026 5:52pm
fides-privacy-center Ignored Ignored Apr 22, 2026 5:52pm

Request Review

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.97%. Comparing base (a533969) to head (26aaefc).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7999      +/-   ##
==========================================
+ Coverage   84.95%   84.97%   +0.01%     
==========================================
  Files         631      631              
  Lines       41185    41245      +60     
  Branches     4781     4787       +6     
==========================================
+ Hits        34989    35047      +58     
- Misses       5110     5113       +3     
+ Partials     1086     1085       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@adamsachs adamsachs force-pushed the ENG-3386-custom-field-system-managed branch from 1e20083 to 3f4eb00 Compare April 22, 2026 17:29
Adds the columns and association table needed for the location-gated
regulatory reporting templates feature in fidesplus:

- CustomFieldDefinition.system_managed — boolean marker for field
  definitions owned by a platform flow (e.g. the reporting-templates
  reconciler). User-created fields default to False.
- CustomReport.system_template_key — stable template identifier
  ("ico", "dpc", "cnil") populated by the reconciler.
- CustomReport.location_code — fides location that gates the template
  ("gb", "ie", "fr"). Both columns are NULL for user-created reports.
- plus_reporting_template_custom_field — M:N association linking
  system-managed CustomReports to the CustomFieldDefinitions they
  reference. Cascades on delete so tearing down a template cleans up
  association rows.

Revises d71c7d274c04 (the true head on main — the correspondence
migrations chain extends through 4738e3e3e850 up to d71c7d274c04).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@adamsachs adamsachs force-pushed the ENG-3386-custom-field-system-managed branch from 3f4eb00 to 26aaefc Compare April 22, 2026 17:52
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