insert into notification_deliveries(
    id,alarm_id,channel,recipient,status,attempt_count,receipt,
    sent_at,delivered_at,created_at,updated_at
)
select 'notification-seed-' || substr(md5(a.id),1,16),a.id,'IN_APP','user-reviewer','DELIVERED',1,
       jsonb_build_object('recipient_name','专业复核人员','source','historical-bootstrap'),
       a.created_at,a.created_at,a.created_at,a.updated_at
from (
    select * from alarms
    where suppressed=false and status<>'closed'
    order by created_at desc
    limit 20
) a
where not exists (
    select 1 from notification_deliveries n where n.alarm_id=a.id and n.channel='IN_APP'
);
