CREATE TABLE IF NOT EXISTS editorial_studio_sessions (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  editorial_topic_id BIGINT UNSIGNED NOT NULL,
  architecture_key VARCHAR(40) NOT NULL,
  formats_json JSON NOT NULL,
  source_dossier_json JSON NOT NULL,
  generated_json JSON NOT NULL,
  status ENUM('prepared','reviewed','rejected') NOT NULL DEFAULT 'prepared',
  created_at DATETIME NOT NULL,
  reviewed_at DATETIME NULL,
  INDEX(editorial_topic_id,created_at),
  FOREIGN KEY(editorial_topic_id) REFERENCES editorial_topics(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
