max / makenotwork
1 file changed,
+4 insertions,
-8 deletions
| @@ -13,14 +13,10 @@ | |||
| 13 | 13 | ALTER TABLE projects ADD COLUMN IF NOT EXISTS cover_s3_key TEXT; | |
| 14 | 14 | ||
| 15 | 15 | -- Backfill from the canonical URL form: strip scheme + host (and any query | |
| 16 | - | -- string) to recover the object key. Stored cover URLs are `{cdn_base}/{s3_key}`, | |
| 17 | - | -- so the path after the host IS the key. This holds because production REQUIRES | |
| 18 | - | -- a CDN (Config::from_env returns MissingCdnBaseUrl otherwise, ultra-fuzz Run 10 | |
| 19 | - | -- Sto S-1); the no-CDN dev fallback stores path-style presigned URLs | |
| 20 | - | -- (`{endpoint}/{bucket}/{key}`) that this regex would mis-key, but that mode is | |
| 21 | - | -- not allowed in production where this backfill runs. Only touch rows that have a | |
| 22 | - | -- URL but no key yet; a URL that isn't an http(s) path with a non-empty path is | |
| 23 | - | -- left NULL (nothing for the worker to protect). | |
| 16 | + | -- string) to recover the object key. Stored cover URLs are always | |
| 17 | + | -- `{cdn_base}/{s3_key}`, so the path after the host IS the key. Only touch rows | |
| 18 | + | -- that have a URL but no key yet; a URL that isn't an http(s) path with a | |
| 19 | + | -- non-empty path is left NULL (nothing for the worker to protect). | |
| 24 | 20 | UPDATE projects | |
| 25 | 21 | SET cover_s3_key = substring(cover_image_url from '^https?://[^/]+/([^?]*)') | |
| 26 | 22 | WHERE cover_image_url IS NOT NULL |