Skip to content

Table: featured_items

This table references:

ColumnTypeNullableNotes
iduuidnoDefault gen_random_uuid()
subject_kindtextnoWhat the placement points at: asset, collection or team. There’s no foreign key because the subject can be any of these; reads join the matching table and drop placements whose subject the caller can’t see. Adding a kind means updating every place the list is repeated (this check, the handler’s validation and error text, the OpenAPI input and response enums, and the admin curation list).
subject_iduuidno-
positionintegernoDefault 0
created_attimestampnoDefault now()
created_by_user_refbigintyes-
scopetextnoDefault 'org'::text
team_iduuidyesReferences teams(id)
band_iduuidyesReferences promo_bands(id). Which surface the placement belongs to: NULL for the featured rail, or a promo band’s id for a card in that band. For band cards, the band’s scope sets the audience and this row’s own scope isn’t used.
  • CONSTRAINT featured_items_scope_check CHECK ((scope = ANY (ARRAY['public'::text, 'org'::text, 'team'::text])))
  • CONSTRAINT featured_items_subject_kind_check CHECK ((subject_kind = ANY (ARRAY['asset'::text, 'collection'::text, 'team'::text])))
  • CONSTRAINT featured_items_team_scope_check CHECK ((((scope = 'team'::text) AND (team_id IS NOT NULL)) OR ((scope <> 'team'::text) AND (team_id IS NULL))))

This is the table’s CREATE TABLE statement. Constraints added with separate ALTER TABLE statements, including foreign-key ON DELETE rules, and indexes are defined elsewhere in the dump; see the complete app/schema.sql.

CREATE TABLE public.featured_items (
id uuid DEFAULT gen_random_uuid() NOT NULL,
subject_kind text NOT NULL,
subject_id uuid NOT NULL,
"position" integer DEFAULT 0 NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
created_by_user_ref bigint,
scope text DEFAULT 'org'::text NOT NULL,
team_id uuid,
band_id uuid,
CONSTRAINT featured_items_scope_check CHECK ((scope = ANY (ARRAY['public'::text, 'org'::text, 'team'::text]))),
CONSTRAINT featured_items_subject_kind_check CHECK ((subject_kind = ANY (ARRAY['asset'::text, 'collection'::text, 'team'::text]))),
CONSTRAINT featured_items_team_scope_check CHECK ((((scope = 'team'::text) AND (team_id IS NOT NULL)) OR ((scope <> 'team'::text) AND (team_id IS NULL))))
);

See the schema overview for context.