GeezerVison is showing github.com — fix(relay): tunnel limit counts abandoned reprovisions and frees fail… · pingdotgg/t3code@9ebca5f
File tree
Expand file treeCollapse file tree
Open diff view settings
migrations/postgres/20261028062605_backfill_withdrawn_tunnel_allocations
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard +12Lines changed: 12 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +-- Teardown claims used to bump updated_at past the link's revoke or publish-only write, so a |
| 2 | +-- failed deprovision now reads as an unfinished relink. Give those rows the updated_at the |
| 3 | +-- current write rule would have left. Touches only withdrawn links' live tunnels; idempotent. |
| 4 | +UPDATE "relay_managed_endpoint_allocations" AS a |
| 5 | +SET "updated_at" = l."updated_at" |
| 6 | +FROM "relay_environment_links" AS l |
| 7 | +WHERE l."user_id" = a."user_id" |
| 8 | + AND l."environment_id" = a."environment_id" |
| 9 | + AND a."tunnel_id" IS NOT NULL |
| 10 | + AND a."tunnel_released_at" IS NULL |
| 11 | + AND (l."revoked_at" IS NOT NULL OR l."managed_tunnels_enabled" = false) |
| 12 | + AND l."updated_at" < a."updated_at"; |