Skip to content

Entity: ProductPhoto

A photo associated with a product. Each product can have multiple photos, stored in Cloudflare R2.

Fields

FieldTypeNullableDefaultDescription
idserialnoautoPrimary key
product_idintegernoFK to product.id
object_keyvarchar(512)noR2 object key (path in the bucket)
mime_typeenum(image/png, image/jpeg)noFile MIME type per ADR-008

Standard columns (created_at, updated_at, deleted_at) are inherited per ADR-007 and should not be listed here.

Relations

RelationTypeTarget entityFKOn delete
productmany-to-oneProductproduct_photo.product_idcascade

Business rules

  • The object_key follows the pattern products/{product_id}/{uuid}.{ext}.
  • The full public URL is derived at read time by prepending R2_PUBLIC_URL to the object_key.

Notes

  • Storing only the object_key (not the full URL) keeps data portable if the R2 bucket or public URL changes.