-- Kaynak sağlığı: hata veren siteler taramadan otomatik çıkarılır
-- (src/lib/pc/health.ts). Uygulama geneli, kullanıcıya ait değil.

create table if not exists store_health (
  source_id    text primary key,
  status       text not null default 'active',
  fail_count   integer not null default 0,
  last_error   text,
  last_ok_at   timestamptz,
  last_fail_at timestamptz,
  removed_at   timestamptz,
  updated_at   timestamptz not null default now()
);

-- Yöneticiye giden (ya da SMTP ayarlı değilse gidemeyen) bildirimler.
create table if not exists problem_log (
  id         serial primary key,
  source_id  text not null,
  subject    text not null,
  body       text not null,
  emailed    boolean not null default false,
  created_at timestamptz not null default now()
);

create index if not exists problem_log_source_idx on problem_log (source_id, created_at desc);
