[openstack-dev] [oslo.db] Proposal: Get rid of deleted column

Ed Leafe ed at openstack.org
Tue Aug 20 19:51:39 UTC 2013

On Aug 20, 2013, at 2:33 PM, Chris Behrens <cbehrens at codestud.com>

> For instances table, we want to make sure 'uuid' is unique.  But we can't put a unique constraint on that alone.  If that instance gets deleted.. we should be able to create another entry with the same uuid without a problem.  So we need a unique constraint on uuid+deleted.  But if 'deleted' is only 0 or 1… we can only have 1 entry deleted and 1 entry not deleted.  Using deleted=`id` to mark deletion solves that problem.  You could use deleted_at… but 2 creates and deletes within the same second would not work. :)

This creates another problem if you ever need to delete this second instance, because now you have two with the same uuid and the same deleted status. 'deleted_at' is slightly better, as the only place it would fail is if all of this happened within the same unit of precision for that time value.

-- Ed Leafe

More information about the OpenStack-dev mailing list