# Phase 11 — Migration and runtime readiness review

## Issues identified and corrected during static review

1. **Sanctum migration collision risk:** the project contained a custom `personal_access_tokens` migration while Laravel Sanctum v4 provides its own migration. The custom duplicate was removed; the package migration is expected to create the token table when Composer dependencies are installed and Sanctum's provider is discovered.
2. **Soft-delete consistency:** `patients` and `facilities` tables have `deleted_at` columns. Their Eloquent models now use Laravel's `SoftDeletes` trait so deleted rows are excluded from normal queries and route binding.
3. **Test source expanded:** encounter signing/locking, appointment check-in and pharmacy stock deduction scenarios are included in the PHPUnit feature suite.
4. **Schema references:** static inspection cross-checks application `DB::table()` references against tables declared by application migrations.

## Runtime blockers

The build environment does not provide Composer, Docker, MySQL/MariaDB, or any PDO database driver. Consequently:
- `composer install` and dependency discovery cannot run;
- Laravel cannot boot without `vendor/autoload.php`;
- migration up/down cannot run;
- PHPUnit cannot connect to a test database;
- Docker image build and service health checks cannot run.

## Required next execution on staging

1. Build dependencies using Composer in CI and commit a reviewed `composer.lock`.
2. Run `composer validate` and dependency vulnerability review.
3. Build Docker image and launch MySQL 8.4, PHP-FPM and Nginx.
4. Run `php artisan migrate:fresh --seed` only on an empty disposable staging database.
5. Run `php artisan test`.
6. Verify `php artisan route:list`, `/up`, login, password change, patient registration and clinical workflows.
7. Run backup/restore and security tests.
8. Capture logs and test results; fix all failures before any production approval.

**No runtime, migration or PHPUnit result is claimed as passed by this source-only review.**


A patient-registry feature test initially relied on the database default `must_change_password=true`, which would redirect the test user before registry access. The fixture now explicitly sets `must_change_password=false`. The Docker deployment guide now correctly separates PHPUnit execution in a development/CI environment from the production image, which excludes dev dependencies.
