fix : 모델, BOM 구성 수정

- 설계용 모델, BOM 기능 추가
This commit is contained in:
2025-09-05 17:59:34 +09:00
parent 41d0afa245
commit d9563c96cb
19 changed files with 1972 additions and 290 deletions

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
// 설계 상위: models
public function up(): void {
Schema::create('models', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('tenant_id')->comment('테넌트ID');
$table->string('code', 100)->comment('모델코드(설계코드)');
$table->string('name', 200)->comment('모델명');
$table->unsignedBigInteger('category_id')->nullable()->comment('카테고리ID(참조용, FK 미설정)');
$table->string('lifecycle', 30)->nullable()->comment('PLANNING/ACTIVE/DEPRECATED 등');
$table->text('description')->nullable();
$table->boolean('is_active')->default(true);
$table->timestamps();
$table->softDeletes();
$table->unique(['tenant_id', 'code'], 'uq_models_tenant_code');
$table->index(['tenant_id', 'is_active'], 'idx_models_tenant_active');
$table->index(['tenant_id', 'category_id'], 'idx_models_tenant_category');
});
}
public function down(): void {
Schema::dropIfExists('models');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
// 설계 버전: model_versions
public function up(): void {
Schema::create('model_versions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('tenant_id')->comment('테넌트ID');
$table->unsignedBigInteger('model_id')->comment('모델ID');
$table->integer('version_no')->comment('버전번호(1..N)');
$table->string('status', 30)->default('DRAFT')->comment('DRAFT/RELEASED');
$table->dateTime('effective_from')->nullable();
$table->dateTime('effective_to')->nullable();
$table->text('notes')->nullable();
$table->boolean('is_active')->default(true);
$table->timestamps();
$table->softDeletes();
$table->unique(['model_id', 'version_no'], 'uq_model_versions_model_ver');
$table->index(['tenant_id', 'status'], 'idx_mv_tenant_status');
$table->index(['tenant_id', 'model_id'], 'idx_mv_tenant_model');
});
}
public function down(): void {
Schema::dropIfExists('model_versions');
}
};

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
// 설계용 BOM 템플릿: bom_templates
public function up(): void {
Schema::create('bom_templates', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('tenant_id')->comment('테넌트ID');
$table->unsignedBigInteger('model_version_id')->comment('모델버전ID');
$table->string('name', 100)->default('Main')->comment('템플릿명');
$table->boolean('is_primary')->default(true)->comment('대표 템플릿 여부');
$table->text('notes')->nullable();
$table->timestamps();
$table->softDeletes();
$table->unique(['model_version_id', 'name'], 'uq_bomtpl_mv_name');
$table->index(['tenant_id', 'model_version_id'], 'idx_bomtpl_tenant_mv');
$table->index(['tenant_id', 'is_primary'], 'idx_bomtpl_tenant_primary');
});
}
public function down(): void {
Schema::dropIfExists('bom_templates');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
// 설계용 BOM 항목: bom_template_items
public function up(): void {
Schema::create('bom_template_items', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('tenant_id')->comment('테넌트ID');
$table->unsignedBigInteger('bom_template_id')->comment('BOM템플릿ID');
$table->string('ref_type', 20)->comment('참조타입: MATERIAL|PRODUCT');
$table->unsignedBigInteger('ref_id')->comment('참조ID(materials.id 또는 products.id)');
$table->decimal('qty', 18, 6)->default(1)->comment('수량');
$table->decimal('waste_rate', 9, 6)->default(0)->comment('로스율');
$table->unsignedBigInteger('uom_id')->nullable()->comment('단위ID(참조용)');
$table->string('notes', 255)->nullable();
$table->integer('sort_order')->default(0);
$table->timestamps();
$table->index(['tenant_id', 'bom_template_id'], 'idx_bomtpl_items_tenant_tpl');
$table->index(['tenant_id', 'ref_type', 'ref_id'], 'idx_bomtpl_items_tenant_ref');
$table->index(['bom_template_id', 'sort_order'], 'idx_bomtpl_items_sort');
});
}
public function down(): void {
Schema::dropIfExists('bom_template_items');
}
};