-- Antifraude da ronda:
-- 1) ordem obrigatoria dos checkpoints (route_order)
-- 2) intervalo minimo entre scans
-- 3) bloqueio de mock location + selfie obrigatoria por scan

SET NAMES utf8mb4;
USE `ponto-sas`;

ALTER TABLE `patrol_checkpoints`
  ADD COLUMN `route_order` INT UNSIGNED NOT NULL DEFAULT 1 AFTER `radius_m`;

ALTER TABLE `tenants`
  ADD COLUMN `app_patrol_require_order` TINYINT(1) NOT NULL DEFAULT 1 AFTER `app_ronda_scanner_enabled`,
  ADD COLUMN `app_patrol_min_interval_seconds` INT UNSIGNED NOT NULL DEFAULT 30 AFTER `app_patrol_require_order`,
  ADD COLUMN `app_patrol_block_mock_location` TINYINT(1) NOT NULL DEFAULT 1 AFTER `app_patrol_min_interval_seconds`,
  ADD COLUMN `app_patrol_require_selfie` TINYINT(1) NOT NULL DEFAULT 1 AFTER `app_patrol_block_mock_location`;

ALTER TABLE `patrol_scans`
  ADD COLUMN `is_mock_location` TINYINT(1) NOT NULL DEFAULT 0 AFTER `distance_to_checkpoint_m`,
  ADD COLUMN `selfie_path` VARCHAR(500) NULL AFTER `is_mock_location`;

-- Ordem sugerida de migrations: 10, 11, 12, 13, 14.
