diff options
author | Boris Pavlovic <boris@pavlovic.me> | 2012-12-24 15:19:28 +0400 |
---|---|---|
committer | Boris Pavlovic <boris@pavlovic.me> | 2013-01-23 17:18:10 +0400 |
commit | 28191baa2b1a65fb86bbbbfc0974495059db6d42 (patch) | |
tree | d1d023297660920e693fe99d39f8499cab1c85cd /nova/utils.py | |
parent | bb108c6bd359e788e0f4cfc53f5933d134fc7cc4 (diff) | |
download | nova-28191baa2b1a65fb86bbbbfc0974495059db6d42.tar.gz nova-28191baa2b1a65fb86bbbbfc0974495059db6d42.tar.xz nova-28191baa2b1a65fb86bbbbfc0974495059db6d42.zip |
Provide creating real unique constraints for columns
Main issue is that we can't create unique constraint for columns, because
we are using soft deletion of entries (set `deleted` column to True).
The main idea is to use `deleted` columns to create unique constraint for
columns. For example (`col1`, `deleted`).
To make (`col1`, `deleted`) unique after entry deletion, we should assign the
value of `id` to `deleted` column.
Change type of `deleted` column from Boolean to table.id.type for all tables.
Change models.soft_delete() method to assign table.id instead of True to
`deleted` column.
Change query.soft_delete() method to assign literal_column("id") instead of True
Change in db.models all occurrences of Table.deleted == False =>
Table.deleted == correct_type (0 or "")
Value of `deleted` property of entries is used in public nova api. To keep API
as is, we should change XMLDictSerializer by converting the type of
`deleted` property to string representation of boolean.
Change db.api.model_query() method to make it work with different types
of `deleted` column.
If we are using as model that is not subclass of NovaBase we should set
parameter base_model as subclass of NovaBase that corresponds to model.
Change in db.api all occurrences of using model_query with model that is not
subclass of NovaBase.
blueprint db-unique-keys
Change-Id: Ie1f67f49a5d085e6371efb63fc23a1c8b25d9464
Diffstat (limited to 'nova/utils.py')
0 files changed, 0 insertions, 0 deletions