-- Website blog posts managed from the superadmin dashboard. CREATE TABLE IF NOT EXISTS website_blog_categories ( id BIGSERIAL PRIMARY KEY, name VARCHAR(120) NOT NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() ); CREATE UNIQUE INDEX IF NOT EXISTS website_blog_categories_name_unique ON website_blog_categories (name); CREATE TABLE IF NOT EXISTS website_blog_posts ( id BIGSERIAL PRIMARY KEY, title VARCHAR(200) NOT NULL, abstract TEXT, main_text_html TEXT, image_url TEXT, category_id BIGINT NOT NULL REFERENCES website_blog_categories (id) ON DELETE RESTRICT, tags TEXT[] NOT NULL DEFAULT '{}', created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() ); CREATE INDEX IF NOT EXISTS idx_website_blog_posts_created_at ON website_blog_posts (created_at DESC); CREATE INDEX IF NOT EXISTS idx_website_blog_posts_category_id ON website_blog_posts (category_id); COMMENT ON TABLE website_blog_posts IS 'IranBay website blog posts edited from the superadmin dashboard.';