# Presentation FK backfill validation - 2026-05-05

Validated locally on tenant `tenancy_demo`.

Commands:
- `php artisan presentation:backfill-fk --tenant=tenancy_demo --dry-run`
- `php artisan presentation:backfill-fk --tenant=tenancy_demo`
- `php artisan presentation:backfill-fk --tenant=tenancy_demo --dry-run`
- `php artisan presentation:health-check --tenant=tenancy_demo`

Result:
- Initial dry-run found `710` `inventory_kardex` rows without FK.
- Initial dry-run found `11` recoverable `inventory_kardex` rows with presentation JSON.
- Real backfill updated `11` `inventory_kardex` rows.
- Prescriptions were already complete: `0` rows missing FK.
- Post-backfill dry-run found `0` additional rows recoverable from JSON.

Cross-check:
- Document kardex rows with `item.presentation.id` and null FK: `0`.
- Sale note kardex rows with `item.presentation.id` and null FK: `0`.
- Purchase kardex rows with `item.presentation.id` and null FK: `0`.
- Prescription rows with null FK: `0`.

Health-check note:
- `presentation:health-check` still reports historical QA data issues:
  - `10` active QA items without any presentation.
  - `270` document/purchase/sale-note kardex rows without FK, but these do not have a recoverable `presentation.id` in their JSON snapshots.
- This means the backfill is complete for records that can be populated from historical JSON; remaining nulls are historical rows without presentation data or non-document inventory movements.

Conclusion:
- Backfill completed successfully for `tenancy_demo`.
- Historical documents were not broken.
- Rows with presentation JSON now have `presentation_unit_type_id` populated.
