id(); $table->string('mutation_number')->unique(); $table->foreignId('from_dealer_id')->constrained('dealers'); $table->foreignId('to_dealer_id')->constrained('dealers'); $table->enum('status', ['pending', 'sent', 'received', 'approved', 'rejected', 'completed', 'cancelled']) ->default('sent'); $table->foreignId('requested_by')->constrained('users'); $table->foreignId('approved_by')->nullable()->constrained('users'); $table->timestamp('approved_at')->nullable(); $table->foreignId('received_by')->nullable()->constrained('users'); $table->timestamp('received_at')->nullable(); $table->text('notes')->nullable(); $table->text('rejection_reason')->nullable(); $table->timestamps(); $table->softDeletes(); // Indexes untuk performa $table->index(['from_dealer_id', 'status']); $table->index(['to_dealer_id', 'status']); $table->index(['status', 'created_at']); $table->index('mutation_number'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('mutations'); } };