max / makenotwork
| 1 | -- Make pending_uploads uniqueness (and its ON CONFLICT target) bucket-aware. |
| 2 | -- |
| 3 | -- The deletion queue (pending_s3_deletions) and is_s3_key_live are already |
| 4 | -- (s3_key, bucket)-scoped; pending_uploads lagged on s3_key alone. Today every |
| 5 | -- pending row is bucket='main', so this is latent, but a key legitimately |
| 6 | -- present in two buckets (main + a future synckit/OTA presign) would collide on |
| 7 | -- INSERT and the ON CONFLICT (s3_key) upsert could refresh or suppress the |
| 8 | -- wrong bucket's row. Align the unique key with the rest of the storage layer. |
| 9 | IF EXISTS idx_pending_uploads_s3_key; |
| 10 | NOT EXISTS idx_pending_uploads_s3_key_bucket |
| 11 | ON pending_uploads(s3_key, bucket); |
| 12 |