-- ============================================
-- Migration: Add auto_read_enabled setting to devices table
-- Purpose: Allow per-device control of auto-read message feature
-- Run this in Supabase SQL Editor
-- ============================================

-- Add column auto_read_enabled with default true (maintain current behavior)
ALTER TABLE public.devices ADD COLUMN IF NOT EXISTS auto_read_enabled BOOLEAN DEFAULT true;

-- Add comment for documentation
COMMENT ON COLUMN public.devices.auto_read_enabled IS 'Automatically mark incoming messages as read. Default: true';

-- Verify the column was added
SELECT
    column_name,
    data_type,
    column_default,
    is_nullable
FROM information_schema.columns
WHERE table_schema = 'public'
  AND table_name = 'devices'
  AND column_name = 'auto_read_enabled';
