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

38 lines
1.5 KiB
PHP
Raw Normal View History

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::create('boms', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tenant_id')->comment('멀티테넌시');
$table->unsignedBigInteger('product_id')->comment('제품ID');
$table->string('code', 30)->comment('BOM코드');
$table->string('name', 100)->comment('BOM명');
$table->unsignedBigInteger('category_id')->comment('카테고리ID(common_codes)');
$table->json('attributes')->nullable()->comment('동적 속성');
$table->string('description', 255)->nullable()->comment('설명');
$table->boolean('is_default')->default(0)->comment('기본BOM여부');
$table->boolean('is_active')->default(1)->comment('사용여부');
$table->unsignedBigInteger('image_file_id')->nullable()->comment('첨부파일ID');
$table->timestamps();
$table->softDeletes();
$table->unique(['tenant_id', 'product_id', 'code']);
$table->foreign('product_id')->references('id')->on('products');
$table->foreign('category_id')->references('id')->on('common_codes');
$table->foreign('image_file_id')->references('id')->on('files');
});
}
public function down()
{
Schema::dropIfExists('boms');
}
};