-- Tipos de ocorrência personalizados (gestor mensal), por tenant

SET NAMES utf8mb4;

USE `ponto-sas`;

CREATE TABLE IF NOT EXISTS `absence_occurrence_presets` (
  `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `tenant_id` BIGINT UNSIGNED NOT NULL,
  `label` VARCHAR(150) NOT NULL,
  `absence_type` ENUM(
    'FERIAS',
    'LICENCA_MEDICA',
    'FOLGA',
    'AUSENCIA',
    'FALTA',
    'FOLGA_COMPENSATORIA',
    'OUTRO'
  ) NOT NULL,
  `sort_order` INT NOT NULL DEFAULT 0,
  `is_active` TINYINT(1) NOT NULL DEFAULT 1,
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,

  KEY `idx_aop_tenant_active` (`tenant_id`, `is_active`, `sort_order`),

  CONSTRAINT `fk_aop_tenant`
    FOREIGN KEY (`tenant_id`) REFERENCES `tenants`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
