summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/migration/0.8.2/migrate_couch_schema/__init__.py15
-rw-r--r--scripts/migration/0.8.2/tests/conftest.py6
2 files changed, 20 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 37e5a525..60214aae 100644
--- a/scripts/migration/0.8.2/migrate_couch_schema/__init__.py
+++ b/scripts/migration/0.8.2/migrate_couch_schema/__init__.py
@@ -119,6 +119,21 @@ def _migrate_sync_docs(db, do_migrate):
for row in view.rows:
old_doc = row['doc']
old_id = old_doc['_id']
+
+ # older schemas used different documents with ids starting with
+ # "u1db_sync" to store sync-related data:
+ #
+ # - u1db_sync_log: was used to store the whole sync log.
+ # - u1db_sync_state: was used to store the sync state.
+ #
+ # if any of these documents exist in the current db, they are leftover
+ # from previous migrations, and should just be removed.
+ if old_id in ['u1db_sync_log', 'u1db_sync_state']:
+ logger.info('removing leftover "u1db_sync_log" document...')
+ if do_migrate:
+ db.delete(old_doc)
+ continue
+
replica_uid = old_id.replace('u1db_sync_', '')
new_id = "%s%s" % (SYNC_DOC_ID_PREFIX, replica_uid)
new_doc = {
diff --git a/scripts/migration/0.8.2/tests/conftest.py b/scripts/migration/0.8.2/tests/conftest.py
index 92d1e17e..8e49891c 100644
--- a/scripts/migration/0.8.2/tests/conftest.py
+++ b/scripts/migration/0.8.2/tests/conftest.py
@@ -31,7 +31,11 @@ initial_docs = [
{'_id': 'doc2', 'u1db_transactions': [(2, 'trans-2'), (4, 'trans-4')]},
{'_id': '_design/docs'},
{'_id': '_design/syncs'},
- {'_id': '_design/transactions', 'views': {'log': {'map': transaction_map}}}
+ {'_id': '_design/transactions',
+ 'views': {'log': {'map': transaction_map}}},
+ # the following should be removed if found in the dbs
+ {'_id': 'u1db_sync_log'},
+ {'_id': 'u1db_sync_state'},
]