Skip to content

Commit

Permalink
Create datastore indexes only if they are not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk authored and amercader committed Mar 6, 2018
1 parent 00ab360 commit eda64f5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ckanext/datastore/db.py
Expand Up @@ -429,8 +429,10 @@ def create_indexes(context, data_dict):
indexes = []

if primary_key is not None:
_drop_indexes(context, data_dict, True)
indexes.append(primary_key)
unique_keys = _get_unique_key(context, data_dict)
if sorted(unique_keys) != sorted(primary_key):
_drop_indexes(context, data_dict, True)
indexes.append(primary_key)

for index in indexes:
if not index:
Expand Down

0 comments on commit eda64f5

Please sign in to comment.