- Admin "Híres emberek": birth data, one photo (S3: DigitalOcean Spaces in production, RustFS in development), a face point that every crop keeps in view, publishing, and a detailed portrait written with its own `celebrity` prompt (third person, by name, from the chart alone). - The photo is stored once (upright JPEG, at most 2000 px, no metadata); next/image makes the sizes from it, so Cloudflare can cache those. - Public list and pages (/hires-emberek), in the sitemap, with a share image showing the face and the chart. - Share images: the wheel's glyphs and numbers are drawn with the card's fonts (inside the SVG image they came out as boxes, on every card). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
59 lines
3.5 KiB
SQL
59 lines
3.5 KiB
SQL
-- Famous people: an admin adds their birth data, one photo and a detailed
|
|
-- analysis written with its own prompt (`celebrity` kind, about them in the
|
|
-- third person). Published ones have a public page and a list.
|
|
--
|
|
-- The chart is an ordinary `charts` row of kind 'celebrity' (so calculation,
|
|
-- recalculation and the worker work as for any chart), owned by the admin
|
|
-- who added it; the user's own lists leave these out.
|
|
|
|
ALTER TABLE charts DROP CONSTRAINT charts_kind_check;
|
|
ALTER TABLE charts ADD CONSTRAINT charts_kind_check CHECK (kind IN ('own', 'person', 'celebrity'));
|
|
|
|
ALTER TABLE analyses DROP CONSTRAINT analyses_kind_check;
|
|
ALTER TABLE analyses ADD CONSTRAINT analyses_kind_check
|
|
CHECK (kind IN ('natal', 'synastry', 'summary', 'forecast', 'tarot', 'celebrity'));
|
|
ALTER TABLE analyses DROP CONSTRAINT analyses_target;
|
|
ALTER TABLE analyses ADD CONSTRAINT analyses_target CHECK (
|
|
(kind IN ('natal', 'summary', 'celebrity') AND chart_id IS NOT NULL AND synastry_id IS NULL AND forecast_id IS NULL)
|
|
OR (kind = 'synastry' AND synastry_id IS NOT NULL AND chart_id IS NULL AND forecast_id IS NULL)
|
|
OR (kind = 'forecast' AND forecast_id IS NOT NULL AND chart_id IS NULL AND synastry_id IS NULL)
|
|
OR (kind = 'tarot' AND tarot IS NOT NULL AND chart_id IS NULL AND synastry_id IS NULL AND forecast_id IS NULL)
|
|
);
|
|
|
|
ALTER TABLE prompt_revisions DROP CONSTRAINT prompt_revisions_kind_check;
|
|
ALTER TABLE prompt_revisions ADD CONSTRAINT prompt_revisions_kind_check
|
|
CHECK (kind IN ('summary', 'natal', 'synastry', 'forecast', 'question', 'celebrity'));
|
|
|
|
ALTER TABLE prompt_previews DROP CONSTRAINT prompt_previews_target;
|
|
ALTER TABLE prompt_previews ADD CONSTRAINT prompt_previews_target CHECK (
|
|
(kind IN ('summary', 'natal', 'celebrity') AND chart_id IS NOT NULL AND synastry_id IS NULL AND forecast_id IS NULL)
|
|
OR (kind = 'synastry' AND synastry_id IS NOT NULL AND chart_id IS NULL AND forecast_id IS NULL)
|
|
OR (kind = 'forecast' AND forecast_id IS NOT NULL AND chart_id IS NULL AND synastry_id IS NULL)
|
|
);
|
|
|
|
CREATE TABLE celebrities (
|
|
id uuid PRIMARY KEY,
|
|
-- Deleting the chart deletes the famous person (and the analyses with it).
|
|
chart_id uuid NOT NULL UNIQUE REFERENCES charts (id) ON DELETE CASCADE,
|
|
name text NOT NULL CHECK (length(name) BETWEEN 1 AND 100),
|
|
-- One line under the name, e.g. "színésznő, énekesnő".
|
|
subtitle text CHECK (subtitle IS NULL OR length(subtitle) BETWEEN 1 AND 160),
|
|
-- The address of the public page: /hires-emberek/<slug>.
|
|
slug text NOT NULL UNIQUE CHECK (slug ~ '^[a-z0-9]+(-[a-z0-9]+)*$'),
|
|
-- The one photo in the object storage (a new upload gets a new key, so
|
|
-- caches never serve an old picture), its size, and the point of the face
|
|
-- (0..1 from the left and from the top) that every crop keeps in view.
|
|
photo_key text,
|
|
photo_width integer,
|
|
photo_height integer,
|
|
focus_x real NOT NULL DEFAULT 0.5 CHECK (focus_x BETWEEN 0 AND 1),
|
|
focus_y real NOT NULL DEFAULT 0.3 CHECK (focus_y BETWEEN 0 AND 1),
|
|
-- NULL: a draft, only admins see it.
|
|
published_at timestamptz,
|
|
created_by uuid REFERENCES users (id) ON DELETE SET NULL,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
CONSTRAINT celebrities_photo CHECK ((photo_key IS NULL) = (photo_width IS NULL) AND (photo_key IS NULL) = (photo_height IS NULL))
|
|
);
|
|
CREATE INDEX celebrities_published_idx ON celebrities (published_at DESC) WHERE published_at IS NOT NULL;
|