USE comptaai_maroc;

ALTER TABLE notifications
  MODIFY type ENUM(
    'new_document_uploaded',
    'ocr_completed',
    'extraction_needs_review',
    'accounting_entry_needs_validation',
    'tva_report_ready',
    'bank_transaction_needs_matching',
    'export_completed',
    'ai_anomaly_detected',
    'new_task',
    'document_rejected',
    'document_needs_correction',
    'tva_report_validated',
    'accounting_report_ready'
  ) NOT NULL;

CREATE TABLE IF NOT EXISTS task_comments (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  task_id BIGINT UNSIGNED NOT NULL,
  user_id BIGINT UNSIGNED NULL,
  comment TEXT NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  KEY task_comments_task_index (task_id),
  KEY task_comments_user_index (user_id),
  CONSTRAINT task_comments_task_fk FOREIGN KEY (task_id) REFERENCES tasks(id) ON DELETE CASCADE,
  CONSTRAINT task_comments_user_fk FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL
) ENGINE=InnoDB;
