ALTER TABLE public.association_fee_rules
  ADD COLUMN IF NOT EXISTS billing_start_date date,
  ADD COLUMN IF NOT EXISTS auto_post_enabled boolean NOT NULL DEFAULT false,
  ADD COLUMN IF NOT EXISTS next_run_date date,
  ADD COLUMN IF NOT EXISTS last_run_date date;

CREATE INDEX IF NOT EXISTS idx_assoc_fee_rules_next_run
  ON public.association_fee_rules (auto_post_enabled, next_run_date)
  WHERE auto_post_enabled = true;