where('status', 'pending') ->update(['status' => 'sent']); // Update existing 'completed' status to 'approved' DB::table('mutations') ->where('status', 'completed') ->update(['status' => 'approved']); // Update the enum to only include valid statuses DB::statement("ALTER TABLE mutations MODIFY COLUMN status ENUM('sent', 'received', 'approved', 'rejected', 'cancelled') DEFAULT 'sent'"); // Update any orphaned mutation_details that reference completed status DB::statement(" UPDATE mutation_details md JOIN mutations m ON md.mutation_id = m.id SET md.quantity_approved = md.quantity_requested WHERE m.status = 'approved' AND md.quantity_approved IS NULL "); } /** * Reverse the migrations. */ public function down(): void { // Restore original enum (if needed) DB::statement("ALTER TABLE mutations MODIFY COLUMN status ENUM('pending', 'sent', 'received', 'approved', 'rejected', 'completed', 'cancelled') DEFAULT 'sent'"); } };