feat: [공정관리] parent_id 트리 구조 도입 — 마이그레이션, 모델 관계, 2depth 검증

This commit is contained in:
김보곤
2026-03-21 15:23:54 +09:00
parent cce4798643
commit 1577d028dc
5 changed files with 88 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('processes', function (Blueprint $table) {
$table->unsignedBigInteger('parent_id')
->nullable()
->after('tenant_id')
->comment('부모 공정 ID (NULL이면 루트)');
$table->foreign('parent_id')
->references('id')
->on('processes')
->onDelete('set null');
$table->index(['tenant_id', 'parent_id']);
});
}
public function down(): void
{
Schema::table('processes', function (Blueprint $table) {
$table->dropForeign(['parent_id']);
$table->dropIndex(['tenant_id', 'parent_id']);
$table->dropColumn('parent_id');
});
}
};