post_images
Overview
A post's pictures, one row each, in the author's order. posts.image_url keeps a copy of the first picture's URL for older
readers. Each picture may carry a caption (words shown under it for everyone) and a description (alternative text,
read by screen readers and shown when the picture does not load). Both are optional; the author can add or change them
after posting, without the post being marked edited (STU-2a, migration 20261016100000_post_image_captions.sql).
posts.image_alt exists from an early schema and is unused: one column cannot describe several pictures.
Columns
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | uuid | No | gen_random_uuid() | Primary key |
post_id | uuid | No | -- | Parent post, cascades on delete |
image_url | text | No | -- | Public URL of the file in the post-images bucket |
position | integer | No | 0 | Display order (0-based) |
caption | text | Yes | -- | Shown under the picture; 1 to 200 characters, trimmed, one line |
alt_text | text | Yes | -- | The picture's description (its alt); 1 to 400 characters, trimmed, one line |
created_at | timestamptz | Yes | now() | Upload time |
The two text columns refuse control characters and line or paragraph separators (CHECKs post_images_caption_shape and
post_images_alt_text_shape).
Access
- Read: "View images of visible posts": a picture is readable wherever its post is (the policy reads
postsunder the reader's own RLS). Signed-out visitors have no access to the table. - Insert / delete: only the author of the post.
- Update: only the author of the post, and only
captionandalt_text: members hold a column-level UPDATE grant on those two columns alone, soimage_url,positionandpost_idcannot change once written.
Uploads
Every photo picked in the composer is re-encoded in the browser before upload (EXIF and GPS dropped, orientation applied); animated GIFs are posted as they are. See ADR-044.
Related
- posts -- Parent post
Last updated: 2026-10-16