feat: [equipment] 설비관리 테이블 마이그레이션 6개 생성
- equipments (설비 마스터) - equipment_inspection_templates (점검항목 템플릿) - equipment_inspections (월간 점검 헤더) - equipment_inspection_details (일자별 점검 결과) - equipment_repairs (수리이력) - equipment_process (설비-공정 피봇)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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('equipment_inspection_templates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
|
||||
$table->unsignedBigInteger('equipment_id')->comment('설비 ID');
|
||||
$table->integer('item_no')->comment('항목번호 (1,2,3,4)');
|
||||
$table->string('check_point', 50)->comment('점검개소 (겉모양, 스위치, 롤러 등)');
|
||||
$table->string('check_item', 100)->comment('점검항목 (청결상태, 작동상태 등)');
|
||||
$table->string('check_timing', 20)->nullable()->comment('시기: operating/stopped');
|
||||
$table->string('check_frequency', 50)->nullable()->comment('주기 (1회/일)');
|
||||
$table->text('check_method')->nullable()->comment('점검방법 및 기준');
|
||||
$table->integer('sort_order')->default(0)->comment('정렬순서');
|
||||
$table->tinyInteger('is_active')->default(1)->comment('사용여부');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['equipment_id', 'item_no'], 'uq_equipment_item_no');
|
||||
$table->index('tenant_id', 'idx_insp_tmpl_tenant');
|
||||
|
||||
$table->foreign('equipment_id')
|
||||
->references('id')
|
||||
->on('equipments')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('equipment_inspection_templates');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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('equipment_inspections', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
|
||||
$table->unsignedBigInteger('equipment_id')->comment('설비 ID');
|
||||
$table->string('year_month', 7)->comment('점검년월 (2026-02)');
|
||||
$table->string('overall_judgment', 10)->nullable()->comment('종합판정: OK/NG');
|
||||
$table->foreignId('inspector_id')->nullable()->comment('점검자 ID (users.id)');
|
||||
$table->text('repair_note')->nullable()->comment('수리내역');
|
||||
$table->text('issue_note')->nullable()->comment('이상내용');
|
||||
$table->foreignId('created_by')->nullable()->comment('생성자 ID');
|
||||
$table->foreignId('updated_by')->nullable()->comment('수정자 ID');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['tenant_id', 'equipment_id', 'year_month'], 'uq_inspection_month');
|
||||
$table->index(['tenant_id', 'year_month'], 'idx_inspection_ym');
|
||||
|
||||
$table->foreign('equipment_id')
|
||||
->references('id')
|
||||
->on('equipments')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('equipment_inspections');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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('equipment_inspection_details', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('inspection_id')->comment('점검 헤더 ID');
|
||||
$table->unsignedBigInteger('template_item_id')->comment('점검항목 템플릿 ID');
|
||||
$table->date('check_date')->comment('점검일');
|
||||
$table->string('result', 10)->nullable()->comment('결과: good/bad/repaired');
|
||||
$table->string('note', 500)->nullable()->comment('비고');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['inspection_id', 'template_item_id', 'check_date'], 'uq_inspection_detail');
|
||||
|
||||
$table->foreign('inspection_id')
|
||||
->references('id')
|
||||
->on('equipment_inspections')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('template_item_id')
|
||||
->references('id')
|
||||
->on('equipment_inspection_templates')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('equipment_inspection_details');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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('equipment_repairs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
|
||||
$table->unsignedBigInteger('equipment_id')->comment('설비 ID');
|
||||
$table->date('repair_date')->comment('수리일');
|
||||
$table->string('repair_type', 20)->comment('보전구분: internal/external');
|
||||
$table->decimal('repair_hours', 5, 1)->nullable()->comment('수리시간');
|
||||
$table->text('description')->nullable()->comment('수리내용');
|
||||
$table->decimal('cost', 15, 2)->nullable()->comment('수리비용');
|
||||
$table->string('vendor', 100)->nullable()->comment('외주업체');
|
||||
$table->foreignId('repaired_by')->nullable()->comment('수리자 ID (users.id)');
|
||||
$table->text('memo')->nullable()->comment('비고');
|
||||
$table->foreignId('created_by')->nullable()->comment('생성자 ID');
|
||||
$table->foreignId('updated_by')->nullable()->comment('수정자 ID');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['tenant_id', 'repair_date'], 'idx_repair_date');
|
||||
$table->index(['tenant_id', 'equipment_id'], 'idx_repair_equipment');
|
||||
|
||||
$table->foreign('equipment_id')
|
||||
->references('id')
|
||||
->on('equipments')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('equipment_repairs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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('equipment_process', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('equipment_id')->comment('설비 ID');
|
||||
$table->unsignedBigInteger('process_id')->comment('공정 ID');
|
||||
$table->tinyInteger('is_primary')->default(0)->comment('주 설비 여부');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['equipment_id', 'process_id'], 'uq_equipment_process');
|
||||
|
||||
$table->foreign('equipment_id')
|
||||
->references('id')
|
||||
->on('equipments')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('process_id')
|
||||
->references('id')
|
||||
->on('processes')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('equipment_process');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user