mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 19:51:14 +00:00
[AZ-284] Autodev baseline + testability refactor
Phase A baseline outputs from /autodev (Steps 1-5): - Problem & solution docs (_docs/00_problem, _docs/01_solution) - Codebase documentation (_docs/02_document) incl. architecture, module-layout, glossary, system-flows, baseline compliance scan - Test specs (blackbox, performance, resilience, security, resource, traceability matrix) - Test task decomposition (_docs/02_tasks/todo): AZ-285..AZ-290 - Testability refactor (_docs/04_refactoring/01-testability-refactoring): - TC-01 Move DownloadedTileInfoV2 + new ExistingTileInfo to Common.DTO - TC-02 Replace dead ISatelliteDownloader API with real signatures - TC-03 GoogleMapsDownloaderV2 implements ISatelliteDownloader - TC-04 TileService depends on ISatelliteDownloader (mockable) - TC-05 DI + endpoints use ISatelliteDownloader - Test runner scripts (scripts/run-tests.sh, run-performance-tests.sh) - Autodev state pointer (_docs/_autodev_state.md) Prepares the codebase for AZ-285..AZ-290 unit/integration test work. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
# Module: DataAccess/DatabaseMigrator
|
||||
|
||||
## Purpose
|
||||
Runs DbUp-based SQL migrations against PostgreSQL on application startup. Ensures the database schema is up to date before the API begins serving requests.
|
||||
|
||||
## Public Interface
|
||||
|
||||
### DatabaseMigrator
|
||||
- Constructor: `DatabaseMigrator(string connectionString, ILogger<DatabaseMigrator>? logger)`
|
||||
- `RunMigrations() → bool`: creates the database if missing (`EnsureDatabase.For.PostgresqlDatabase`), then runs all embedded SQL scripts matching `.Migrations.` from the DataAccess assembly. Returns `true` on success.
|
||||
|
||||
## Internal Logic
|
||||
- Uses `DbUp.DeployChanges` fluent API targeting PostgreSQL
|
||||
- Scripts are embedded resources filtered by path containing `.Migrations.`
|
||||
- Logs to console via DbUp's built-in `LogToConsole()`
|
||||
- On failure, logs the error and returns `false`
|
||||
|
||||
## Dependencies
|
||||
- NuGet: `dbup-postgresql` (6.0.3)
|
||||
- `Microsoft.Extensions.Logging`
|
||||
- Embedded SQL resources from `SatelliteProvider.DataAccess/Migrations/`
|
||||
|
||||
## Consumers
|
||||
- `Program.cs` — instantiated directly (not via DI) and called during startup. If migration fails, the application throws and does not start.
|
||||
|
||||
## Migrations (11 scripts)
|
||||
1. `001_CreateTilesTable.sql`
|
||||
2. `002_CreateRegionsTable.sql`
|
||||
3. `003_CreateIndexes.sql`
|
||||
4. `004_AddVersionColumn.sql`
|
||||
5. `005_CreateRoutesTables.sql`
|
||||
6. `006_AddStitchTilesToRegions.sql`
|
||||
7. `007_AddRouteMapFields.sql`
|
||||
8. `008_AddGeofenceFlagToRouteRegions.sql`
|
||||
9. `009_AddGeofencePolygonIndex.sql`
|
||||
10. `010_AddTilesZipToRoutes.sql`
|
||||
11. `011_AddTileCoordinates.sql`
|
||||
|
||||
## Configuration
|
||||
Receives connection string directly as constructor parameter.
|
||||
|
||||
## External Integrations
|
||||
PostgreSQL — DDL operations via DbUp.
|
||||
|
||||
## Security
|
||||
None directly, but controls schema evolution.
|
||||
|
||||
## Tests
|
||||
No dedicated tests.
|
||||
Reference in New Issue
Block a user