ALTER TABLE posts DROP CONSTRAINT IF EXISTS posts_status_check;

ALTER TABLE posts
  ADD CONSTRAINT posts_status_check CHECK (status IN ('published', 'draft', 'members', 'private'));

ALTER TABLE pages
  ADD COLUMN IF NOT EXISTS status TEXT NOT NULL DEFAULT 'published';

ALTER TABLE pages DROP CONSTRAINT IF EXISTS pages_status_check;

ALTER TABLE pages
  ADD CONSTRAINT pages_status_check CHECK (status IN ('published', 'draft', 'private'));

CREATE INDEX IF NOT EXISTS pages_status_updated_at_idx
  ON pages (status, updated_at DESC);
