Provide unique constraints on all tables

Registered by Viktor Serhieiev

 - add unique indexes on (`column`, `deleted`), and set `deleted`=`id` instead of `deleted`=1 after delete.
 - handle duplicate key errors.
 - add missing unique constraints to models

Blueprint information

Status:
Complete
Approver:
John Griffith
Priority:
Low
Drafter:
Viktor Serhieiev
Direction:
Approved
Assignee:
Roman Podoliaka
Definition:
Obsolete
Series goal:
None
Implementation:
Started
Milestone target:
None
Started by
Viktor Serhieiev
Completed by
Sean McGinnis

Related branches

Sprints

Whiteboard

(smcginnis): Marking obsolete as this has been sitting out there for a long time. If this is still needed, please submit a new bp.

⬥ Tables that should have UC:

⚒ quotas
UC on columns (project_id, resource, deleted). Based on quota_get() api function

⚒ quota_classes
UC on (class_name, resource, deleted). Based on quota_class_get() api function

- quota_usages
UC on (project_id, resource, deleted). Based on quota_usage_get() api function

- reservations
UC on (uuid, deleted). Based on reservation_get() api function

- services
UC on columns
(topic, disabled, deleted, host) - based on service_get_by_host_and_topic() api function
(host, binary, deleted) - based on service_get_by_args() api function

- iscsi_targets
UC on (volume_id, deleted). Based on volume_get_iscsi_target_num() api function

- volume_metadata
UC on (volume_id, key, deleted). Based on volume_metadata_get_item() api function

- volume_types
UC on (name, deleted). Based on volume_type_get_by_name() api function

- volume_type_extra_specs
UC on (volume_type_id, key, deleted). Based on volume_type_extra_specs_get_item() api function

Gerrit topic: https://review.openstack.org/#q,topic:bp/db-unique-keys,n,z

Addressed by: https://review.openstack.org/40660
    Change column type from boolean to `id` type.

Addressed by: https://review.openstack.org/41631
    Added unique constarint to quotas table.

Addressed by: https://review.openstack.org/41639
    Added unique constarint to quota_classes table.

(?)

Work Items

Dependency tree

* Blueprints in grey have been implemented.

This blueprint contains Public information 
Everyone can see this information.