···530530 unique (repo_at, label_at)
531531 );
532532533533+ create table if not exists notifications (
534534+ id integer primary key autoincrement,
535535+ recipient_did text not null,
536536+ actor_did text not null,
537537+ type text not null,
538538+ entity_type text not null,
539539+ entity_id text not null,
540540+ read integer not null default 0,
541541+ created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
542542+ repo_id integer references repos(id),
543543+ issue_id integer references issues(id),
544544+ pull_id integer references pulls(id)
545545+ );
546546+547547+ create table if not exists notification_preferences (
548548+ id integer primary key autoincrement,
549549+ user_did text not null unique,
550550+ repo_starred integer not null default 1,
551551+ issue_created integer not null default 1,
552552+ issue_commented integer not null default 1,
553553+ pull_created integer not null default 1,
554554+ pull_commented integer not null default 1,
555555+ followed integer not null default 1,
556556+ pull_merged integer not null default 1,
557557+ issue_closed integer not null default 1,
558558+ email_notifications integer not null default 0
559559+ );
560560+533561 create table if not exists migrations (
534562 id integer primary key autoincrement,
535563 name text unique
536564 );
537565538538- -- indexes for better star query performance
566566+ -- indexes for better performance
567567+ create index if not exists idx_notifications_recipient_created on notifications(recipient_did, created desc);
568568+ create index if not exists idx_notifications_recipient_read on notifications(recipient_did, read);
539569 create index if not exists idx_stars_created on stars(created);
540570 create index if not exists idx_stars_repo_at_created on stars(repo_at, created);
541571 `)