Files
compor-academy/server/migrations/011_home_banners.sql
Cauê Faleiros 5b86d6ef0d
All checks were successful
CI / Validate frontend and API (push) Successful in 35s
CI / Build and publish Docker images (push) Successful in 20s
feat: manage homepage banner carousel
2026-09-04 16:44:34 -03:00

22 lines
960 B
SQL

-- Homepage banners are independent editorial content. A banner can either
-- reference a course (and always use its current cover) or use an uploaded
-- image stored in Bunny Storage.
create table home_banners (
id uuid primary key default gen_random_uuid(),
kind text not null check (kind in ('course', 'custom')),
course_id uuid references courses(id) on delete cascade,
image_url text,
title text not null default '',
description text not null default '',
position integer not null check (position > 0),
created_at timestamptz not null default now(),
updated_at timestamptz not null default now(),
constraint home_banners_source_check check (
(kind = 'course' and course_id is not null and image_url is null) or
(kind = 'custom' and course_id is null and image_url is not null)
),
unique (position)
);
create trigger home_banners_set_updated_at before update on home_banners for each row execute function set_updated_at();