-- Add target_month (YYYY-MM-01 format) and completed_at to payables ALTER TABLE public.payables ADD COLUMN target_month DATE DEFAULT date_trunc('month', CURRENT_DATE)::date; ALTER TABLE public.payables ADD COLUMN completed_at TIMESTAMP WITH TIME ZONE; -- Update existing payables to have target_month based on due_date or created_at UPDATE public.payables SET target_month = COALESCE(date_trunc('month', due_date)::date, date_trunc('month', created_at)::date);