alter table if exists final_result_products
  add column if not exists score real,
  add column if not exists is_match boolean,
  add column if not exists match_bucket text not null default 'matched',
  add column if not exists reason text not null default '',
  add column if not exists has_phone_contact boolean not null default false,
  add column if not exists qualification_status text not null default 'qualified',
  add column if not exists contact_collection_reason text not null default '';

create index if not exists idx_final_result_products_match_bucket
  on final_result_products(match_bucket);

alter table if exists merchant_contacts
  add column if not exists source_match_bucket text not null default 'manual';

create index if not exists idx_merchant_contacts_source_match_bucket
  on merchant_contacts(source_match_bucket);
