# Refactor: fix null ILogger passed to DatabaseMigrator at startup

**Task**: AZ-351_refactor_fix_null_logger_migrator
**Name**: Fix null logger to DatabaseMigrator
**Description**: Resolve `ILogger<DatabaseMigrator>` directly from DI instead of casting `ILogger<Program>`, which always returns null.
**Complexity**: 2 points
**Dependencies**: None
**Component**: Api
**Tracker**: AZ-351
**Epic**: AZ-350

## Problem

`SatelliteProvider.Api/Program.cs:82-83` does `app.Services.GetRequiredService<ILogger<Program>>() as ILogger<DatabaseMigrator>`. The cast between unrelated generic instantiations always returns null. `DatabaseMigrator` runs with a null logger, so any migration failure path that depends on logging is silent.

## Outcome

- `DatabaseMigrator` receives a real `ILogger<DatabaseMigrator>` instance from DI.
- Migration log entries appear in startup output and persist to log sinks.
- 37 unit + 5 smoke tests stay green.

## Scope

### Included
- Replace the `as` cast with `app.Services.GetRequiredService<ILogger<DatabaseMigrator>>()`.
- Confirm `DatabaseMigrator`'s constructor logs at least one entry on success and one on failure (already present, just verify).

### Excluded
- Changing `DatabaseMigrator`'s logging strategy or log levels.
- Adding migration-related metrics or observability beyond what already exists.

## Acceptance Criteria

**AC-1: Migrator receives a real logger**
Given the post-refactor `Program.cs`
When the host starts
Then `DatabaseMigrator` is constructed with a non-null `ILogger<DatabaseMigrator>` (verifiable by a unit test or by inspecting startup logs).

**AC-2: Tests stay green**
Given the post-refactor build
When `scripts/run-tests.sh --smoke` runs
Then all 37 unit + 5 smoke scenarios pass.

## Constraints

- No DI graph reorder.
- No public API change.

## Risks & Mitigation

**Risk 1: hidden assumption that logger may be null**
- *Risk*: `DatabaseMigrator` may have a defensive null-check that masked the bug.
- *Mitigation*: keep the null-check during this change; remove it in a follow-up only after we confirm via tests that the live logger is always provided.

Full change entry: `_docs/04_refactoring/03-code-quality-refactoring/list-of-changes.md` (C01).
