-- Migration 133: Notification grouping (v0.10.5 F554)
-- Aggregate similar notifications (e.g. "3 people liked your track")

ALTER TABLE notifications
ADD COLUMN IF NOT EXISTS group_key VARCHAR(255),
ADD COLUMN IF NOT EXISTS actor_count INT NOT NULL DEFAULT 1,
ADD COLUMN IF NOT EXISTS metadata JSONB DEFAULT '{}';

CREATE INDEX IF NOT EXISTS idx_notifications_group_key ON notifications(group_key) WHERE group_key IS NOT NULL;

COMMENT ON COLUMN notifications.group_key IS 'Semantic key for grouping (e.g. like:track:uuid)';
COMMENT ON COLUMN notifications.actor_count IS 'Number of actors when grouped';
COMMENT ON COLUMN notifications.metadata IS 'Additional data (actor_ids, etc.)';
