ALTER TABLE raw_post_media
  ADD COLUMN IF NOT EXISTS editor_hidden BOOLEAN NOT NULL DEFAULT FALSE,
  ADD COLUMN IF NOT EXISTS editor_added BOOLEAN NOT NULL DEFAULT FALSE,
  ADD COLUMN IF NOT EXISTS editor_uploaded_by BIGINT REFERENCES admin_users(id) ON DELETE SET NULL,
  ADD COLUMN IF NOT EXISTS editor_uploaded_at TIMESTAMPTZ;

CREATE INDEX IF NOT EXISTS idx_raw_post_media_editor_visible
ON raw_post_media(raw_post_id, sort_order, id)
WHERE editor_hidden = FALSE;
