summaryrefslogtreecommitdiff
path: root/scripts/migration/0.8.2/migrate_couch_schema
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2016-08-19 14:31:52 -0300
committerdrebs <drebs@leap.se>2016-08-23 18:48:26 -0300
commit2025916a1c4d4518e714086e2144be0e83c95d9e (patch)
treebaf72b1ce527b58be616b15543cad87082ece9a5 /scripts/migration/0.8.2/migrate_couch_schema
parent9ae70f3cd0eaad378c73416a0cc18f62199082b0 (diff)
[pkg] ignore existing correct gen docs in couch schema migrate script
Diffstat (limited to 'scripts/migration/0.8.2/migrate_couch_schema')
-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):