Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Create _hour_start_at and _day_start_at for every collection
Browse files Browse the repository at this point in the history
  • Loading branch information
phss committed Oct 18, 2013
1 parent 0abce56 commit 2cfd298
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions migrations/005_add_hour_and_day_start.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Add _week_start_at field to all documents in all collections
Add _hour_start_at and _day_start_at field to all documents in all collections
"""
import logging

Expand All @@ -15,14 +15,13 @@ def up(db):
collection = db[name]
query = {
"_timestamp": {"$exists": True},
"_month_start_at": {"$exists": False}
"_day_start_at": {"$exists": False}
}
for document in collection.find(query):
document['_timestamp'] = utc(document['_timestamp'])
if '_week_start_at' in document:
document.pop('_week_start_at')
if '_updated_at' in document:
document.pop('_updated_at')
for attr in ['_updated_at', '_week_start_at', '_month_start_at']:
if attr in document:
document.pop(attr)
record = Record(document)

collection.save(record.to_mongo())

0 comments on commit 2cfd298

Please sign in to comment.