-- PropEase — run this once in phpMyAdmin → SQL tab
-- Adds engagement stat columns to your listings table

ALTER TABLE listings
  ADD COLUMN IF NOT EXISTS views          INT NOT NULL DEFAULT 0,
  ADD COLUMN IF NOT EXISTS likes_count    INT NOT NULL DEFAULT 0,
  ADD COLUMN IF NOT EXISTS wishlist_count INT NOT NULL DEFAULT 0,
  ADD COLUMN IF NOT EXISTS skip_count     INT NOT NULL DEFAULT 0,
  ADD COLUMN IF NOT EXISTS share_count    INT NOT NULL DEFAULT 0,
  ADD COLUMN IF NOT EXISTS contact_count  INT NOT NULL DEFAULT 0,
  ADD COLUMN IF NOT EXISTS chat_count     INT NOT NULL DEFAULT 0;

-- If buyer_activity was created before 'view' was an accepted action,
-- widen the enum so apiPost('view', id) can be persisted per buyer.
ALTER TABLE buyer_activity
  MODIFY COLUMN action ENUM('view','like','wishlist','skip','chat','contact','share') NOT NULL;
