CREATE TABLE IF NOT EXISTS sync_log (
  id              INT AUTO_INCREMENT PRIMARY KEY,
  company_id      INT NOT NULL,
  sync_type       ENUM('full', 'incremental', 'cdc') NOT NULL,
  status          ENUM('running', 'completed', 'failed') NOT NULL,
  started_at      TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  completed_at    DATETIME DEFAULT NULL,
  records_synced  INT DEFAULT 0,
  error_message   TEXT DEFAULT NULL,
  FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
