CREATE TYPE banner_level AS ENUM ('info', 'important', 'critical');

CREATE TABLE IF NOT EXISTS announcement_banners (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  message TEXT NOT NULL,
  level banner_level NOT NULL DEFAULT 'info',
  starts_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  ends_at TIMESTAMPTZ,
  created_by UUID REFERENCES users(id) ON DELETE SET NULL,
  created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_banners_starts_at ON announcement_banners (starts_at);
CREATE INDEX idx_banners_ends_at ON announcement_banners (ends_at);
