-- =====================================================================
--  ALTALYS PROTECTION — Observations de la direction sur la main courante
--  L'écriture de l'agent reste intacte et scellée.
--  La direction ajoute une observation rattachée, que l'agent consulte.
--  Import via phpMyAdmin > moso8599_altalys > Importer
-- =====================================================================
SET NAMES utf8mb4;

CREATE TABLE IF NOT EXISTS `mce_observations` (
  `id`          BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `ecriture_id` BIGINT UNSIGNED NOT NULL,
  `auteur`      VARCHAR(120) NOT NULL,
  `texte`       TEXT NOT NULL,
  `cree_le`     DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `lu_le`       DATETIME NULL,
  PRIMARY KEY (`id`),
  KEY `idx_ecriture` (`ecriture_id`),
  KEY `idx_lu` (`lu_le`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Le type « rectification » n'est plus utilisé : l'observation le remplace
DELETE FROM `mce_types` WHERE `code` = 'rectification';
