diff --git a/database/migrations/2026_02_03_100000_create_vehicle_logs_table.php b/database/migrations/2026_02_03_100000_create_vehicle_logs_table.php new file mode 100644 index 0000000..ccfc7af --- /dev/null +++ b/database/migrations/2026_02_03_100000_create_vehicle_logs_table.php @@ -0,0 +1,54 @@ +id(); + $table->unsignedBigInteger('tenant_id')->index(); + $table->unsignedBigInteger('vehicle_id')->index(); + + // 운행 정보 + $table->date('log_date')->comment('운행 날짜'); + $table->string('department', 50)->nullable()->comment('부서'); + $table->string('driver_name', 50)->comment('운전자 성명'); + $table->enum('trip_type', ['commute_to', 'commute_from', 'business', 'personal']) + ->comment('구분: 출근용, 퇴근용, 업무용, 비업무'); + + // 출발지 + $table->enum('departure_type', ['home', 'office', 'client', 'other'])->nullable() + ->comment('출발지 분류: 자택, 회사, 거래처, 기타'); + $table->string('departure_name', 100)->nullable()->comment('출발지명'); + $table->string('departure_address', 200)->nullable()->comment('출발지 주소'); + + // 도착지 + $table->enum('arrival_type', ['home', 'office', 'client', 'other'])->nullable() + ->comment('도착지 분류: 자택, 회사, 거래처, 기타'); + $table->string('arrival_name', 100)->nullable()->comment('도착지명'); + $table->string('arrival_address', 200)->nullable()->comment('도착지 주소'); + + // 주행 정보 + $table->unsignedInteger('distance_km')->comment('주행거리(km)'); + $table->string('note', 200)->nullable()->comment('비고'); + + $table->timestamps(); + $table->softDeletes(); + + // 외래키 + $table->foreign('vehicle_id')->references('id')->on('corporate_vehicles')->cascadeOnDelete(); + + // 인덱스 + $table->index(['tenant_id', 'vehicle_id', 'log_date']); + }); + } + + public function down(): void + { + Schema::dropIfExists('vehicle_logs'); + } +};