From 4ed6bb54f1cc96ee0a8b98914c98b94edc1d1b1c Mon Sep 17 00:00:00 2001 From: drebs Date: Fri, 19 Aug 2016 12:14:40 -0300 Subject: [pkg] add leftovers deletion to couch scehma migration script Previous versions of the couchdb schema used documents "u1db_sync_log" and "u1db_sync_state" to store sync metadata. At some point this was changed, but the documents might have stayed as leftovers. This commit adds the deletion of such documents to the migration script. --- scripts/migration/0.8.2/migrate_couch_schema/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'scripts/migration/0.8.2/migrate_couch_schema') 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 = { -- cgit v1.2.3