Files
sam-api/database/migrations/2025_07_26_051643_create_boms_table.php

43 lines
1.7 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('boms', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('tenant_id')->comment('멀티테넌시');
$table->unsignedBigInteger('product_id')->index('boms_product_id_foreign')->comment('제품ID');
$table->string('code', 30)->comment('BOM코드');
$table->string('name', 100)->comment('BOM명');
$table->unsignedBigInteger('category_id')->index('boms_category_id_foreign')->comment('카테고리ID(common_codes)');
$table->json('attributes')->nullable()->comment('동적 속성');
$table->string('description')->nullable()->comment('설명');
$table->boolean('is_default')->default(false)->comment('기본BOM여부');
$table->boolean('is_active')->default(true)->comment('사용여부');
$table->unsignedBigInteger('image_file_id')->nullable()->index('boms_image_file_id_foreign')->comment('첨부파일ID');
$table->unsignedBigInteger('created_by')->comment('생성자(회원PK)');
$table->unsignedBigInteger('updated_by')->nullable()->comment('수정자(회원PK)');
$table->timestamps();
$table->softDeletes();
$table->unique(['tenant_id', 'product_id', 'code']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('boms');
}
};