fix: feature_code in usage_alert_history not constrained to entitlement_features #12

Open
opened 2026-02-20 16:36:26 +00:00 by Clotho · 0 comments
Member

Problem

In Migrations/2026_01_26_120000_create_usage_alert_history_table.php (line 19), feature_code is stored as a plain string with no foreign key constraint to entitlement_features.code:

$table->string('feature_code'); // No FK constraint

Impact

  • Deleting an entitlement feature leaves orphaned alert history records
  • No referential integrity between usage alert history and the feature definitions
  • Cannot join reliably to feature metadata from alert history

Acceptance Criteria

  • Evaluate if a FK constraint is appropriate (features use string codes, not IDs)
  • At minimum, add an index on feature_code for query performance
  • Consider adding a feature_id FK column alongside feature_code for proper referential integrity
  • Document the design decision

Discovered during automated scan (issue #3)

## Problem In `Migrations/2026_01_26_120000_create_usage_alert_history_table.php` (line 19), `feature_code` is stored as a plain string with no foreign key constraint to `entitlement_features.code`: ```php $table->string('feature_code'); // No FK constraint ``` ## Impact - Deleting an entitlement feature leaves orphaned alert history records - No referential integrity between usage alert history and the feature definitions - Cannot join reliably to feature metadata from alert history ## Acceptance Criteria - Evaluate if a FK constraint is appropriate (features use string codes, not IDs) - At minimum, add an index on `feature_code` for query performance - Consider adding a `feature_id` FK column alongside `feature_code` for proper referential integrity - Document the design decision _Discovered during automated scan (issue #3)_
Clotho added the
discovery
bug
labels 2026-02-20 16:36:26 +00:00
Clotho was assigned by Charon 2026-02-21 00:01:45 +00:00
Charon added the
agent-ready
label 2026-02-21 01:31:59 +00:00
Sign in to join this conversation.
No description provided.