-- #migration 2026_10_19_001
-- @mentions dans les publications et les commentaires (CDC n° 11). Une ligne par membre mentionne dans un contenu.
--  - subject_type / subject_id : 'post' ou 'comment' et son identifiant.
--  - Le texte du contenu garde « @Prenom N. » tel que tape ; cette table dit QUI est mentionne (identifiants, jamais deduits du texte).
--  - Supprimee avec le contenu (posts_delete_post / posts_delete_comment).
CREATE TABLE IF NOT EXISTS mentions (
  id           BIGINT       NOT NULL AUTO_INCREMENT,
  subject_type ENUM('post','comment') NOT NULL,
  subject_id   BIGINT       NOT NULL,
  member_id    VARCHAR(40)  NOT NULL,
  created_at   DATETIME     NOT NULL DEFAULT UTC_TIMESTAMP(),
  PRIMARY KEY (id),
  UNIQUE KEY uq_mention (subject_type, subject_id, member_id),
  KEY idx_mention_member (member_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
