Files
Aut.ManagementFaculty/db/migrations/013_news.sql
T

22 lines
708 B
SQL

-- News items shown on /news. Separate from articles (long-form insights).
CREATE TABLE IF NOT EXISTS news_items (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
banner_image_url TEXT NOT NULL,
body TEXT NOT NULL,
gallery_images JSONB NOT NULL DEFAULT '[]',
published_at DATE NOT NULL,
published BOOLEAN DEFAULT true,
created_at TIMESTAMPTZ DEFAULT now(),
updated_at TIMESTAMPTZ DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_news_items_published_at
ON news_items (published, published_at DESC);
DROP TRIGGER IF EXISTS trg_news_items_set_updated_at ON news_items;
CREATE TRIGGER trg_news_items_set_updated_at
BEFORE UPDATE ON news_items
FOR EACH ROW EXECUTE FUNCTION set_updated_at();