summaryrefslogtreecommitdiff
path: root/scripts/migration
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/migration')
-rw-r--r--scripts/migration/0.8.2/migrate_couch_schema/__init__.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/scripts/migration/0.8.2/migrate_couch_schema/__init__.py b/scripts/migration/0.8.2/migrate_couch_schema/__init__.py
index 66ae960b..c3eb9c3d 100644
--- a/scripts/migration/0.8.2/migrate_couch_schema/__init__.py
+++ b/scripts/migration/0.8.2/migrate_couch_schema/__init__.py
@@ -7,6 +7,7 @@ import logging
from couchdb import Server
from couchdb import ResourceNotFound
+from couchdb import ResourceConflict
from leap.soledad.common.couch import GENERATION_KEY
from leap.soledad.common.couch import TRANSACTION_ID_KEY
@@ -100,7 +101,15 @@ def _migrate_transaction_log(db, do_migrate):
}
logger.info('creating gen doc: %s' % (gen_doc_id))
if do_migrate:
- db.save(doc)
+ try:
+ db.save(doc)
+ except ResourceConflict:
+ # this gen document already exists. if documents are the same,
+ # continue with migration.
+ existing_doc = db.get(gen_doc_id)
+ for key in [GENERATION_KEY, DOC_ID_KEY, TRANSACTION_ID_KEY]:
+ if existing_doc[key] != doc[key]:
+ raise
def _migrate_config_doc(db, do_migrate):