Skip to content

Schema: content ​

The content schema manages forum and community content — threads, replies, tags, reactions, translations, and reaction aggregates.

In Community Edition, this schema should be documented as the home of threads and shared discovery metadata, while versioned lenses live in the lenses schema.

Tables ​

threads ​

Forum discussion threads created by lensers.

ColumnTypeNotes
iduuid (PK)
lenser_iduuidFK → lensers.profiles, default lensers.get_auth_lenser_id()
visibilityvisibility_enumpublic, community, private
view_countintegerCached counter
reply_countintegerCached counter, updated by trigger
thumbnail_urltextOptional thread thumbnail
linked_lens_iduuidOptional link to a related lens
prompt_datajsonbDeprecated compatibility field
created_at / updated_attimestamptz

thread_replies ​

Replies within a thread.

ColumnTypeNotes
iduuid (PK)
thread_iduuidFK → threads
lenser_iduuidFK → lensers.profiles
contenttextReply body
parent_reply_iduuidFK → thread_replies (nested replies), nullable
deleted_attimestamptzSoft delete timestamp; NULL = active
created_at / updated_attimestamptz

entity_translations ​

Polymorphic translation table used for content entities.

ColumnTypeNotes
iduuid (PK)
entity_typeentity_type_enumCommunity Edition commonly uses thread, thread_reply, lens, workflow
entity_iduuidReferences the typed entity
language_codetextFK → core.languages(code) ON DELETE RESTRICT
titletext
descriptiontextOptional
contenttextBody text
paramsjsonbOptional structured metadata
is_originalbooleantrue for the author's original language version
created_attimestamptz

Unique constraint: (entity_type, entity_id, language_code)

reactions ​

Unified polymorphic reactions table for threads, replies, lenses, and workflows.

ColumnTypeNotes
iduuid (PK)
entity_typeentity_type_enumthread, thread_reply, lens, workflow
entity_iduuidReferences the typed entity
lenser_iduuidFK → lensers.profiles
reactionreaction_enumlike, love, clap, saved, copy
created_attimestamptz

Uniqueness: Partial unique index (entity_type, entity_id, lenser_id, reaction) WHERE reaction <> 'copy'. Copy reactions are unlimited; all other reaction types are deduplicated per user per entity.

tags ​

Taxonomy system for categorizing content.

ColumnTypeNotes
iduuid (PK)
nametextTag name
slugtextURL-safe identifier
visibilitytag_visibility_enumpublic, private, hidden

tag_map ​

Junction table linking tags to entities.

ColumnTypeNotes
iduuid (PK)
tag_iduuidFK → tags
entity_typeentity_type_enumtypically thread, lens, workflow
entity_iduuidPolymorphic reference

tag_suggestions ​

AI-generated tag suggestions for content entities.

ColumnTypeNotes
iduuid (PK)
entity_typeentity_type_enum
entity_iduuid
ai_model_iduuidFK → ai.models(id) ON DELETE SET NULL. NULL = source unknown or model deleted.
statussuggestion_status_enumpending, accepted, rejected. Default pending.
created_attimestamptz

reports ​

User-submitted content reports.

ColumnTypeNotes
iduuid (PK)
reporter_lenser_iduuidFK → lensers.profiles
entity_typeentity_type_enum
entity_iduuid
reasonreport_reason_enumspam, harassment, misinformation, off_topic, other
created_attimestamptz

media_library ​

Uploaded media files linked to lensers.

ColumnTypeNotes
iduuid (PK)
lenser_iduuidFK → lensers.profiles
urltextStorage URL
mime_typetext

Trigger chain ​

  • thread_replies_after_insert → increments threads.reply_count
  • trg_sync_thread_count → updates analytics.lenser_stats.thread_count
  • tg_xp_thread_created → awards XP via xp.apply()
  • ensure_public_tag → prevents attaching non-public tags

Enums ​

EnumValues
visibility_enumpublic, community, private
tag_visibility_enumpublic, private, hidden
entity_type_enumthread, thread_reply, lens, workflow
reaction_enumlike, love, clap, saved, copy
report_reason_enumspam, harassment, misinformation, off_topic, other
suggestion_status_enumpending, accepted, rejected