Skip to content

Commit

Permalink
Utilize Transaction Management for case where Data already exists (#1623
Browse files Browse the repository at this point in the history
)
  • Loading branch information
scottx611x committed Mar 1, 2017
1 parent b01ad23 commit d48e1e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion refinery/core/migrations/0005_ontology_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def forwards(apps, schema_editor):
# Attempt to save Ontology objects. If an IntegrityError is raised
# upon saving an object we continue as it already exists.
try:
ontology.save()
with transaction.atomic():
ontology.save()
except IntegrityError:
continue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ def forwards(apps, schema_editor):
# Attempt to save FileExtension objects. If an IntegrityError is raised
# upon saving an object we continue as it already exists.
try:
file_extension.save()
with transaction.atomic():
file_extension.save()
except IntegrityError:
continue

Expand Down

0 comments on commit d48e1e1

Please sign in to comment.