mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 11:11:14 +00:00
51b572108a
Captures the post-implementation autodev gates for AZ-484 multi-source tile storage: - Step 12 (Test-Spec Sync): added 7 AC rows (AZ-484 AC-1..AC-7) and a PT-07 NFR row to traceability-matrix.md; added PT-07 scenario to performance-tests.md. - Step 13 (Update Docs): refreshed data_model.md (tiles columns + indexes + selection rule + UPSERT contract + migrations 012/013), module-layout.md (Common/Enums section with L-001 guidance, DataAccess imports-from now lists 6 sites), 6 module / component docs to reflect the new repo signatures, source/captured_at fields, and Dapper enum bypass workaround. ripple_log_cycle1.md records zero out-of-scope ripple. - Step 14 (Security Audit): PASS_WITH_WARNINGS - 0 Critical, 0 High, 5 Medium, 5 Low. AZ-484 itself added zero new findings. Hardening items (Postgres default creds, .env in build context, GMaps key rotation, ASP.NET Core 8.0.21 -> 8.0.25, rate limiter) recorded for separate tickets. - Step 15 (Performance Test): all PT-01..PT-07 scenarios Unverified (non-blocking); PT-07 baseline-comparison harness deferred to a leftover for next cycle. - Step 16 (Deploy): cycle deploy report covering migration safety, rollback path, post-deploy verification, security caveats. Co-authored-by: Cursor <cursoragent@cursor.com>
2.4 KiB
2.4 KiB
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. Returnstrueon success.
Internal Logic
- Uses
DbUp.DeployChangesfluent 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 (13 scripts)
001_CreateTilesTable.sql002_CreateRegionsTable.sql003_CreateIndexes.sql004_AddVersionColumn.sql005_CreateRoutesTables.sql006_AddStitchTilesToRegions.sql007_AddRouteMapFields.sql008_AddGeofenceFlagToRouteRegions.sql009_AddGeofencePolygonIndex.sql010_AddTilesZipToRoutes.sql011_AddTileCoordinates.sql012_DropTileVersionConstraint.sql— drops the legacy 5-col(latitude, longitude, tile_zoom, tile_size_meters, version)unique index, replaces with 4-colidx_tiles_unique_location(preparation for AZ-484).013_AddTileSourceAndCapturedAt.sql— AZ-484 multi-source tile storage. Transactional. Addssource(VARCHAR(32) NOT NULL DEFAULT 'google_maps') andcaptured_at(TIMESTAMP NOT NULL) columns; backfills existing rows withsource='google_maps',captured_at=created_at; dropsidx_tiles_unique_locationand creates 5-colidx_tiles_unique_location_sourceon(latitude, longitude, tile_zoom, tile_size_meters, source). Idempotent against partial replays.
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.