-- MSIN-4401 — Kit : forcer sections fiche inscriptions ouvertes
-- Prérequis : inscriptions_eve_roles (accès v2)
-- Notes prod : idempotent (ajoute la colonne seulement si absente)

SET NAMES utf8mb4;

SET @col_exists := (
  SELECT COUNT(*)
  FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'inscriptions_eve_roles'
    AND COLUMN_NAME = 'role_fiche_sections_open'
);

SET @sql := IF(
  @col_exists = 0,
  'ALTER TABLE `inscriptions_eve_roles`
     ADD COLUMN `role_fiche_sections_open` tinyint(1) unsigned NOT NULL DEFAULT 0
       COMMENT ''MSIN-4401 — 1 = toutes les sections de la fiche inscriptions ouvertes''
       AFTER `role_grants_all`',
  'SELECT ''role_fiche_sections_open already exists'' AS info'
);

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
