63 lines
1.8 KiB
PHP
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;
|
|
}
|
|
}
|
|
}
|
|
}
|