-- Phase 21: fix items imported as inactive by earlier Bulk Import versions
-- Safe target: only items created after the first item import job, when import logs exist.
START TRANSACTION;

UPDATE items
SET is_active = 1
WHERE is_active = 0
  AND EXISTS (SELECT 1 FROM import_jobs WHERE import_type = 'items')
  AND created_at >= (SELECT MIN(created_at) FROM import_jobs WHERE import_type = 'items');

COMMIT;

-- If you intentionally imported all items and they are all inactive with no import logs,
-- run this manually after review:
-- UPDATE items SET is_active = 1 WHERE is_active = 0;
