title: How can safely assign an incrementing ID to a subset of objects?
body: <p>I have an <code>Order</code> object which can be in an unpaid or paid state. When an order is paid, I want to set an <code>order_number</code> which should be an incrementing number.</p>
  
  <p>Sounds easy enough, but I'm worried about collisions. I can imagine one order having an <code>order_number</code> stored in memory, about to save and then another order saves itself, using that number, now the one in memory should be recalculated, but how?</p>