Commit d4e27f4
ENG-3324: Address review comments on the inheritance data model
* **Rename migration file** to ``xx_2026_05_13_0900_6ebb8e54e130_...`` —
the previous filename was dated 2026-04-09 but the rebased
``down_revision`` (``e3f4a5b6c7d8``) is from 2026-04-23, leaving the
migration filename apparently predating its predecessor. Fix the
docstring ``Revises:`` to match the actual ``down_revision`` and bump
``Create Date`` to today.
* **Fix ``server_default`` for the ``source`` column** — ``server_default``
treats plain strings as raw SQL expressions, so ``server_default="explicit"``
rendered ``DEFAULT explicit`` (unquoted identifier) rather than
``DEFAULT 'explicit'``. Use ``sa.text("'explicit'")`` in both the migration
and the ORM model (matching the ``sa.text("true")`` pattern already used
for the ``inherit_system_stewards`` column).
* **Add DB-level CHECK constraints on ``monitorsteward.source``**:
* ``ck_monitorsteward_source_values``: ``source IN ('explicit', 'inherited')``
— prevents an API-only sentinel (like ``"both"``) from being persisted
even if application code misuses the enum.
* ``ck_monitorsteward_inherited_has_system``: ``source != 'inherited' OR
source_system_id IS NOT NULL`` — encodes the domain invariant directly
at the DB level since inherited rows are populated by separate logic.
Mirrored in the ORM ``__table_args__`` so the constraints are visible at
the model level too.
* **Remove ``StewardSource.both`` from the fides enum** — the value is
API-only (computed when a user has rows of both sources on a monitor)
and mixing it into a DB-backed ``StrEnum`` is a footgun. Keep the enum
pure DB-side; fidesplus moves the response-layer attribution (including
``both``) to its own schema module that references these values rather
than redefining them.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent 2444eac commit d4e27f4
2 files changed
Lines changed: 50 additions & 11 deletions
File tree
- src/fides/api
- alembic/migrations/versions
- models/detection_discovery
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
84 | 99 | | |
85 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
86 | 113 | | |
87 | 114 | | |
88 | 115 | | |
| |||
Lines changed: 20 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
4 | 11 | | |
5 | 12 | | |
6 | 13 | | |
7 | 14 | | |
8 | 15 | | |
9 | | - | |
| 16 | + | |
10 | 17 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 18 | + | |
| 19 | + | |
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
19 | | - | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
48 | | - | |
| 52 | + | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| |||
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
64 | 76 | | |
0 commit comments