Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(615)

Unified Diff: charmworld/migrations/versions/026_convert_comma_constraints.py

Issue 90420043: Fix migration wrt invalid constraints.
Patch Set: Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « [revision details] ('k') | charmworld/migrations/versions/tests/test_migrations.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: charmworld/migrations/versions/026_convert_comma_constraints.py
=== modified file 'charmworld/migrations/versions/026_convert_comma_constraints.py'
--- charmworld/migrations/versions/026_convert_comma_constraints.py 2014-04-22 14:05:42 +0000
+++ charmworld/migrations/versions/026_convert_comma_constraints.py 2014-04-22 18:22:29 +0000
@@ -28,7 +28,16 @@
for bundle_data in bundles:
if 'inherits' in bundle_data['data']:
del bundle_data['data']['inherits']
- convert_bundle_constraints(bundle_data['data'])
+ try:
+ convert_bundle_constraints(bundle_data['data'])
+ except ValueError as e:
+ # This bundle has constraints that are invalid or no longer
+ # supported. Simply skip the bundle.
+ log.warning('Bundle has invalid constraint. Skipping {}'.format(
+ bundle_data['_id']))
+ log.warning(e.message)
+ target_db.bundles.remove(bundle_data['_id'])
+ continue
basket_id = '{}/{}'.format(
bundle_data['basket_name'],
bundle_data['basket_revision'])
« no previous file with comments | « [revision details] ('k') | charmworld/migrations/versions/tests/test_migrations.py » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b