Skip to content

Commit

Permalink
migration: add migration for user models
Browse files Browse the repository at this point in the history
Since the `User` schema has been changed, add
a migration for it.

Signed-off-by: Jeny Sadadia <[email protected]>
  • Loading branch information
Jeny Sadadia committed Nov 2, 2023
1 parent 3cc1fc0 commit a8133f7
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions migrations/20231102101356_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

Check warning on line 1 in migrations/20231102101356_user.py

View workflow job for this annotation

GitHub Actions / Lint

Module name "20231102101356_user" doesn't conform to snake_case naming style
#
# Copyright (C) 2022 Collabora Limited
# Author: Jeny Sadadia <[email protected]>

"""
Migration for User schema
"""

name = '20231102101356_user'
dependencies = ['20221014061654_set_timeout']


def upgrade(db: "pymongo.database.Database"):
users = db.user.find()
for user in users:
db.user.replace_one(
{
"_id": user['_id']
},
{
"_id": user['_id'],
"email": user['profile']['email'],
"hashed_password": user['profile']['hashed_password'],
"is_active": 1,
"is_superuser": 0,
"is_verified": 0,
"username": user['profile']['username'],
"groups": user['profile']['groups']
},
)


def downgrade(db: "pymongo.database.Database"):
pass

0 comments on commit a8133f7

Please sign in to comment.