mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 12:31:13 +00:00
581dff206e
AZ-357 — eliminate year-based tile cache expiry (LF-1): - Migration 012: drop 5-col unique index, dedupe by (lat,lon,zoom, size) keeping max(updated_at), add new 4-col unique index, make version column nullable + drop default. Column itself preserved per coderule (column drops require explicit confirmation; tracked in AZ-373 / C20). - TileEntity.Version, TileMetadata.Version, DownloadTileResponse. Version: int -> int? (HTTP shape preserved; field still in JSON). - TileService.DownloadAndStoreTilesAsync: drop currentVersion year computation and the .Where(t => t.Version == currentVersion) cache filter. BuildTileEntity: drop year arg; write Version=null. - TileRepository: ON CONFLICT now 4-col; lookup queries ORDER BY updated_at DESC instead of version DESC. - Tests: replace inverted BT02b with positive AZ357_AC1 (prior-year cached tile is reused). Add BuildTileEntity_ DoesNotPopulateVersion_AZ357 to enforce the no-write contract. - 69 unit + 5 smoke + 3 stub-contract integration tests pass. Cumulative code review (batches 7-9, 7 tasks): VERDICT=PASS. Report at _docs/03_implementation/reviews/batch_09_review.md. Zero Critical/High/Medium/Low findings. Architecture baseline remains clean. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
1.2 KiB
SQL
32 lines
1.2 KiB
SQL
-- AZ-357 / C06: drop year-based versioning from the tile uniqueness key.
|
|
-- The 'version' column itself is preserved (intentionally; column drops require
|
|
-- explicit confirmation per coderule.mdc). This migration:
|
|
-- 1. Drops the 5-column unique index that includes version.
|
|
-- 2. Dedupes pre-existing duplicates by the new 4-column key, keeping the row
|
|
-- with the highest updated_at (tie-break: highest id).
|
|
-- 3. Recreates the unique index without version.
|
|
-- 4. Makes the version column nullable and drops its default so new rows can
|
|
-- be inserted without writing a meaningless year value.
|
|
|
|
DROP INDEX IF EXISTS idx_tiles_unique_location;
|
|
|
|
DELETE FROM tiles
|
|
WHERE id IN (
|
|
SELECT id
|
|
FROM (
|
|
SELECT id,
|
|
ROW_NUMBER() OVER (
|
|
PARTITION BY latitude, longitude, tile_zoom, tile_size_meters
|
|
ORDER BY updated_at DESC, id DESC
|
|
) AS rn
|
|
FROM tiles
|
|
) ranked
|
|
WHERE rn > 1
|
|
);
|
|
|
|
CREATE UNIQUE INDEX idx_tiles_unique_location
|
|
ON tiles(latitude, longitude, tile_zoom, tile_size_meters);
|
|
|
|
ALTER TABLE tiles ALTER COLUMN version DROP NOT NULL;
|
|
ALTER TABLE tiles ALTER COLUMN version DROP DEFAULT;
|