-- Banners de propaganda do app (painel inicial) — cadastrados pelo RH por tenant.
SET NAMES utf8mb4;
USE `ponto-sas`;

CREATE TABLE IF NOT EXISTS `tenant_app_banners` (
  `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `tenant_id` BIGINT UNSIGNED NOT NULL,
  `image_url` VARCHAR(512) NOT NULL,
  `link_url` VARCHAR(512) NULL,
  `title` VARCHAR(200) NULL COMMENT 'Texto alternativo / legenda opcional',
  `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_tab_tenant_active_sort` (`tenant_id`, `is_active`, `sort_order`, `id`),

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