feat: manage homepage banner carousel
This commit is contained in:
21
server/migrations/011_home_banners.sql
Normal file
21
server/migrations/011_home_banners.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- 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();
|
||||
Reference in New Issue
Block a user