-- add_pages_pictures.sql -- -- Adds the image URLs found on crawled pages to `pages.pictures`. -- -- Purpose: -- The crawler stores every absolute image URL of a page (img src, -- srcset, /, og:image, twitter:image, link -- rel="image_src") in `pages.pictures`, so the search UI can offer an -- image tab without downloading or storing the images themselves. -- -- Run once on the jonassearch database as its owner, e.g.: -- psql -h 127.0.0.1 -p 25432 -U jonassearch -d jonassearch \ -- -f add_pages_pictures.sql -- -- Safe to run repeatedly (IF NOT EXISTS) and safe while the crawler is -- running: the column is added as a nullable text[] and existing rows -- are not rewritten. The crawler always writes an array (possibly -- empty) from version 5 on; queries treat NULL and '{}' the same. -- -- If the column already exists (e.g. created by an earlier schema), the -- statement is a no-op and the stored data is left untouched. ALTER TABLE pages ADD COLUMN IF NOT EXISTS pictures text[]; -- New rows without an explicit value get an empty array. This only -- changes table metadata; it does not rewrite existing rows. ALTER TABLE pages ALTER COLUMN pictures SET DEFAULT '{}';