Add migration to set profile modified date (#1832)
If modified field doesn't exist on older browser profiles, set it equal to created date to match what we do for new profile creation.
This commit is contained in:
parent
523ad68880
commit
18e5ed94f1
@ -17,7 +17,7 @@ from pymongo.errors import InvalidName
|
|||||||
from .migrations import BaseMigration
|
from .migrations import BaseMigration
|
||||||
|
|
||||||
|
|
||||||
CURR_DB_VERSION = "0026"
|
CURR_DB_VERSION = "0027"
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
"""
|
||||||
|
Migration 0027 - Profile modified date fallback
|
||||||
|
"""
|
||||||
|
|
||||||
|
from btrixcloud.migrations import BaseMigration
|
||||||
|
|
||||||
|
|
||||||
|
MIGRATION_VERSION = "0027"
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(BaseMigration):
|
||||||
|
"""Migration class."""
|
||||||
|
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
def __init__(self, mdb, **kwargs):
|
||||||
|
super().__init__(mdb, migration_version=MIGRATION_VERSION)
|
||||||
|
|
||||||
|
async def migrate_up(self):
|
||||||
|
"""Perform migration up.
|
||||||
|
|
||||||
|
If profile doesn't have modified date, set to created
|
||||||
|
"""
|
||||||
|
# pylint: disable=duplicate-code
|
||||||
|
profiles = self.mdb["profiles"]
|
||||||
|
try:
|
||||||
|
await profiles.update_many(
|
||||||
|
{"modified": None}, [{"$set": {"modified": "$created"}}]
|
||||||
|
)
|
||||||
|
# pylint: disable=broad-exception-caught
|
||||||
|
except Exception as err:
|
||||||
|
print(
|
||||||
|
f"Error adding modified date to profiles: {err}",
|
||||||
|
flush=True,
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user