ALTER TABLE tasks
  ADD COLUMN IF NOT EXISTS anonymous_quota_date DATE;

UPDATE tasks
SET anonymous_quota_date = (created_at AT TIME ZONE 'Asia/Shanghai')::date
WHERE anonymous_units_reserved > 0
  AND anonymous_quota_date IS NULL;

CREATE INDEX IF NOT EXISTS idx_tasks_anonymous_reservation_pending
  ON tasks(id)
  WHERE anonymous_units_reserved > 0;
