Files
sam-api/app/Providers/MigrationServiceProvider.php
hskwon cc206fdbed style: Laravel Pint 코드 포맷팅 적용
- PSR-12 스타일 가이드 준수
- 302개 파일 스타일 이슈 자동 수정
- 코드 로직 변경 없음 (포맷팅만)
2025-11-06 17:45:49 +09:00

63 lines
1.8 KiB
PHP

<?php
namespace App\Providers;
use Illuminate\Database\Events\MigrationsEnded;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
class MigrationServiceProvider extends ServiceProvider
{
public function register()
{
//
}
public function boot()
{
// 마이그레이션 완료 후 자동으로 관계 문서 업데이트
Event::listen(MigrationsEnded::class, function (MigrationsEnded $event) {
$this->updateRelationshipsAfterMigration();
});
}
private function updateRelationshipsAfterMigration(): void
{
try {
// 논리적 관계 문서 자동 업데이트
Artisan::call('db:update-relationships');
// Git에 자동 커밋 (선택사항)
if (config('database.auto_commit_relationships', false)) {
$this->autoCommitRelationships();
}
\Log::info('✅ 마이그레이션 후 논리적 관계 문서 업데이트 완료');
} catch (\Exception $e) {
\Log::error('❌ 논리적 관계 문서 업데이트 실패: '.$e->getMessage());
}
}
private function autoCommitRelationships(): void
{
$commands = [
'git add LOGICAL_RELATIONSHIPS.md',
'git commit -m "docs: 마이그레이션 후 논리적 관계 자동 업데이트
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>"',
];
foreach ($commands as $command) {
exec($command, $output, $returnCode);
if ($returnCode !== 0) {
\Log::warning("Git 명령 실행 실패: {$command}");
break;
}
}
}
}