verifyNameColumnMigration($context); $this->clearLayoutCache($context); $context->logger->info('[v0.6.0] 업그레이드 완료'); } catch (\Exception $e) { $context->logger->error("[v0.6.0] 업그레이드 실패: {$e->getMessage()}"); throw $e; } } /** * name 컬럼 마이그레이션 검증 * * @param UpgradeContext $context 업그레이드 컨텍스트 */ private function verifyNameColumnMigration(UpgradeContext $context): void { if (! Schema::hasTable('ecommerce_user_addresses')) { $context->logger->warning('[v0.6.0] ecommerce_user_addresses 테이블이 존재하지 않습니다.'); return; } $columnType = Schema::getColumnType('ecommerce_user_addresses', 'name'); if ($columnType === 'json') { throw new \Exception('name 컬럼이 아직 json 타입입니다. 마이그레이션을 먼저 실행하세요.'); } // NULL 값 레코드 검출 $nullCount = UserAddress::whereNull('name') ->orWhere('name', '') ->count(); if ($nullCount > 0) { $context->logger->warning("[v0.6.0] name이 비어있는 배송지 {$nullCount}건 발견 — 수동 확인 필요"); } $context->logger->info('[v0.6.0] 배송지명 컬럼 마이그레이션 검증 완료'); } /** * 레이아웃 캐시를 클리어합니다. * * @param UpgradeContext $context 업그레이드 컨텍스트 */ private function clearLayoutCache(UpgradeContext $context): void { try { Artisan::call('template:cache-clear'); $context->logger->info('[v0.6.0] 템플릿 캐시 클리어 완료'); } catch (\Exception $e) { $context->logger->warning("[v0.6.0] 템플릿 캐시 클리어 실패: {$e->getMessage()}"); } } }