_targetDB === null) { $this->_targetDB = \Config\Database::connect('default'); } return $this->_targetDB; } /** * 공통 마이그레이션 처리 로직 */ final protected function execute(MigrationProcessInterface $processor, array $rows, string $functionName): void { $this->getTargetDB()->transStart(); try { $cnt = 1; foreach ($rows as $row) { $processor->process($row, $cnt); $cnt++; } echo "{$functionName} 작업을 완료하였습니다."; $this->getTargetDB()->transCommit(); } catch (\Exception $e) { $this->getTargetDB()->transRollback(); echo "{$functionName} 작업을 실패하였습니다.\n--------------\n" . $e->getMessage() . "\n--------------\n"; } } }