-- Drop the foreign key constraint on user_id so notifications can reference
-- either users or team_members depending on receiver_type.
ALTER TABLE notifications
    DROP CONSTRAINT IF EXISTS notifications_user_id_fkey;

-- Add a receiver_type column to distinguish between user and team_member recipients.
ALTER TABLE notifications
    ADD COLUMN IF NOT EXISTS receiver_type TEXT NOT NULL DEFAULT 'user'
    CHECK (receiver_type IN ('user', 'team_member'));
