52 lines
2.8 KiB
PHP
52 lines
2.8 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(): void
|
||
|
|
{
|
||
|
|
Schema::create('equipments', function (Blueprint $table) {
|
||
|
|
$table->id();
|
||
|
|
$table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
|
||
|
|
$table->string('equipment_code', 20)->comment('설비코드 (KD-M-001 형식)');
|
||
|
|
$table->string('name', 100)->comment('설비명');
|
||
|
|
$table->string('equipment_type', 50)->nullable()->comment('설비유형 (포밍기/미싱기/샤링기/V컷팅기/절곡기/프레스/드릴)');
|
||
|
|
$table->string('specification', 255)->nullable()->comment('규격');
|
||
|
|
$table->string('manufacturer', 100)->nullable()->comment('제조사');
|
||
|
|
$table->string('model_name', 100)->nullable()->comment('모델명');
|
||
|
|
$table->string('serial_no', 100)->nullable()->comment('제조번호');
|
||
|
|
$table->string('location', 100)->nullable()->comment('위치 (1공장-1F, 2공장-절곡 등)');
|
||
|
|
$table->string('production_line', 50)->nullable()->comment('생산라인 (스라트/스크린/절곡)');
|
||
|
|
$table->date('purchase_date')->nullable()->comment('구입일');
|
||
|
|
$table->date('install_date')->nullable()->comment('설치일');
|
||
|
|
$table->decimal('purchase_price', 15, 2)->nullable()->comment('구입가격');
|
||
|
|
$table->integer('useful_life')->nullable()->comment('내용연수');
|
||
|
|
$table->string('status', 20)->default('active')->comment('상태: active/idle/disposed');
|
||
|
|
$table->date('disposed_date')->nullable()->comment('폐기일');
|
||
|
|
$table->foreignId('manager_id')->nullable()->comment('담당자 ID (users.id)');
|
||
|
|
$table->string('photo_path', 500)->nullable()->comment('설비사진 경로');
|
||
|
|
$table->text('memo')->nullable()->comment('비고');
|
||
|
|
$table->tinyInteger('is_active')->default(1)->comment('사용여부');
|
||
|
|
$table->integer('sort_order')->default(0)->comment('정렬순서');
|
||
|
|
$table->foreignId('created_by')->nullable()->comment('생성자 ID');
|
||
|
|
$table->foreignId('updated_by')->nullable()->comment('수정자 ID');
|
||
|
|
$table->foreignId('deleted_by')->nullable()->comment('삭제자 ID');
|
||
|
|
$table->timestamps();
|
||
|
|
$table->softDeletes();
|
||
|
|
|
||
|
|
$table->unique(['tenant_id', 'equipment_code'], 'uq_equipment_code');
|
||
|
|
$table->index(['tenant_id', 'status'], 'idx_equipment_status');
|
||
|
|
$table->index(['tenant_id', 'production_line'], 'idx_equipment_line');
|
||
|
|
$table->index(['tenant_id', 'equipment_type'], 'idx_equipment_type');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public function down(): void
|
||
|
|
{
|
||
|
|
Schema::dropIfExists('equipments');
|
||
|
|
}
|
||
|
|
};
|