Files
sam-api/database/migrations/2025_07_23_125353_create_parts_table.php
hskwon 609ac39ffb feat : 테이블 및 DB 마이그레이션 파일 추가
products
  - common_codes
  - parts
  - products
  - files
  - price_histories
  - boms
  - bom_items

  boards
  - boards
  - board_settings
  - posts
  - board_comments
  - board_files
  - post_custom_field_values

  permissions
  - menus
  - roles
  - user_menu_permissions
  - role_menu_permissions

  tenants
  - tenants
  - plans
  - subscriptions
  - payments
2025-07-23 15:41:01 +09:00

36 lines
1.4 KiB
PHP

<?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('parts', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tenant_id')->comment('멀티테넌시');
$table->string('code', 30)->comment('부품코드');
$table->string('name', 100)->comment('부품명');
$table->unsignedBigInteger('category_id')->comment('카테고리ID(common_codes)');
$table->unsignedBigInteger('part_type_id')->nullable()->comment('부품타입ID(common_codes)');
$table->string('unit', 20)->nullable()->comment('단위');
$table->json('attributes')->nullable()->comment('동적 속성');
$table->string('description', 255)->nullable()->comment('설명');
$table->tinyInteger('is_active')->default(1)->comment('사용여부');
$table->timestamps();
$table->softDeletes();
$table->unique(['tenant_id','code']);
$table->foreign('category_id')->references('id')->on('common_codes');
$table->foreign('part_type_id')->references('id')->on('common_codes');
});
}
public function down()
{
Schema::dropIfExists('parts');
}
};