-- Cameras: add an "iframe / embed" source alongside Hik-Connect and manual URLs.
-- A farm can paste an embed URL (or full <iframe> code) and PFMIS renders the
-- live stream in an iframe. Adds the 'iframe' provider option and an embed_url
-- column. Safe / idempotent.

-- 1) allow 'iframe' as a provider (MODIFY is safe to re-run).
ALTER TABLE cameras
  MODIFY COLUMN provider ENUM('hikconnect','manual','iframe') NOT NULL DEFAULT 'hikconnect';

-- 2) add the embed_url column if it isn't there yet.
SET @has := (SELECT COUNT(*) FROM information_schema.columns
             WHERE table_schema = DATABASE() AND table_name = 'cameras' AND column_name = 'embed_url');
SET @sql := IF(@has = 0, 'ALTER TABLE cameras ADD COLUMN embed_url VARCHAR(1000) NULL AFTER snapshot_url', 'SELECT 1');
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
