congress/releasenotes/notes/policy_name_unique_db_constraint-22d658e4b17e0388.yaml
Eric K 5b7c9cd121 prevent duplicate policy names using constraint
Previous patch used table locking to prevent duplicate names.
https://review.openstack.org/#/c/378365/

This new patch specifies uniqueness constraint on the name column of
db table to accomplish the same result, with the added benefit of
avoiding the problems that come with table locking:
- requires backend-specific code
- does not support some popular multi-master DBs (eg. Galera)

Complication:
For the purpose of preserving an audit trail, rows in the policies
table were soft deleted only, making the name column non-unique.

changes:
- old policies table split into two new tables:
  - policies for the active policies
  - policiesdeleted for the deleted policies
- unique name enforced on the new policies table
- on adding a new policy, corresponding row is added to policies
table
- On deleting a policy, corresponding row is copied to
policiesdeleted table, soft-deleted from policiesdeteled, and
hard-deleted from policies table

Closes-Bug: 1638763

Change-Id: If95bf63fe2a4990f6f314d700bd7927ee1d46e3c
2016-11-04 19:04:04 -07:00

9 lines
360 B
YAML

---
upgrade:
- Added a new database table policiesdeleted to hold soft-deleted
policies. table:policies column:name type changed from Text() to
String(255) to support uniqueness constraint.
Necessary migration scripts are included in congress/db/migration/.
Migration aborts without effect if any existing policy name is longer than
255.