-- Migration: Add contact channel preferences to users
-- Date: 2026-01-28
-- Description: Users can choose preferred contact methods and visibility

-- Add contact preference columns
ALTER TABLE users ADD COLUMN IF NOT EXISTS contact_prefer_email BOOLEAN DEFAULT TRUE;
ALTER TABLE users ADD COLUMN IF NOT EXISTS contact_prefer_phone BOOLEAN DEFAULT TRUE;
ALTER TABLE users ADD COLUMN IF NOT EXISTS contact_prefer_portal BOOLEAN DEFAULT TRUE;
ALTER TABLE users ADD COLUMN IF NOT EXISTS contact_note TEXT;

-- Comments
COMMENT ON COLUMN users.contact_prefer_email IS 'User prefers contact via email';
COMMENT ON COLUMN users.contact_prefer_phone IS 'User prefers contact via phone';
COMMENT ON COLUMN users.contact_prefer_portal IS 'User prefers contact via portal messages';
COMMENT ON COLUMN users.contact_note IS 'Additional note about contact preferences (e.g. best hours)';

-- Grant permissions
GRANT SELECT, UPDATE ON users TO nordabiz_app;
