# HG changeset patch # User Dirk Olmes # Date 1552354721 -3600 # Node ID 75b81da8d7a581ff3f94d8245a80406b586842de # Parent f79be01821c4846eed354433bea8b8a0a9c7de5d convert the feed entry timestamps to arango compatible date strings in migration diff -r f79be01821c4 -r 75b81da8d7a5 migrate_couch_to_arango.py --- a/migrate_couch_to_arango.py Wed Jan 30 07:11:10 2019 +0100 +++ b/migrate_couch_to_arango.py Tue Mar 12 02:38:41 2019 +0100 @@ -34,6 +34,12 @@ date_string = couch_date.strftime('%Y-%m-%dT%H:%M:%S.000') arango_doc[key] = date_string +def convert_date_tuple(couch_doc, arango_doc, key): + tuple = couch_doc[key] + couch_date = datetime(*tuple) + date_string = couch_date.strftime('%Y-%m-%dT%H:%M:%S.000') + arango_doc[key] = date_string + def migrate_rest(document): if document['_id'].startswith('_design'): return @@ -47,12 +53,14 @@ migrate_preferences(document) else: print('how to migrate ' + document['_id']) - except KeyError: + except KeyError as err: print('**** migrate error ' + str(document)) def migrate_feed_entry(couch_doc): arango_doc = arango_feed_entry.createDocument() copy(couch_doc, arango_doc) + convert_date_tuple(couch_doc, arango_doc, 'create_timestamp') + convert_date_tuple(couch_doc, arango_doc, 'updated') feed_id = arango_doc['feed'] feed_id = feed_mapping[feed_id] arango_doc['feed'] = feed_id