Files
sam-api/database/migrations/2025_07_26_051643_create_parts_table.php
kent b436b635c2 fix : 테이블 추가 및 수정 신규로 작성 (generator 설치)
composer require --dev kitloong/laravel-migrations-generator
php artisan migrate:generate
2025-07-26 05:22:58 +09:00

40 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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('parts', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('tenant_id')->comment('멀티테넌시');
$table->string('code', 30)->comment('부품코드');
$table->string('name', 100)->comment('부품명');
$table->unsignedBigInteger('category_id')->index('parts_category_id_foreign')->comment('카테고리ID(common_codes)');
$table->unsignedBigInteger('part_type_id')->nullable()->index('parts_part_type_id_foreign')->comment('부품타입ID(common_codes)');
$table->string('unit', 20)->nullable()->comment('단위');
$table->json('attributes')->nullable()->comment('동적 속성');
$table->string('description')->nullable()->comment('설명');
$table->tinyInteger('is_active')->default(1)->comment('사용여부');
$table->timestamps();
$table->softDeletes();
$table->unique(['tenant_id', 'code']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('parts');
}
};