-
-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove user data from couch user model #34805
Changes from 1 commit
07d5a70
160d540
45137f3
8e813e2
983b087
d04391c
5081177
ca7845f
ab0ed8a
a181308
da40b4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# One-off migration, June 2024 | ||
|
||
from itertools import chain | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from corehq.apps.domain_migration_flags.api import once_off_migration | ||
from corehq.apps.users.models import CommCareUser | ||
from corehq.dbaccessors.couchapps.all_docs import ( | ||
get_doc_count_by_type, | ||
|
@@ -16,13 +16,18 @@ | |
class Command(BaseCommand): | ||
help = "Populate SQL user data from couch" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this migration just removes couch data not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh whoops you're right - I forgot to update the help text. Let me do that now |
||
|
||
def handle(self, **options): | ||
db = CommCareUser.get_db() | ||
count = (get_doc_count_by_type(db, 'WebUser') | ||
+ get_doc_count_by_type(db, 'CommCareUser')) | ||
all_ids = chain(iter_all_doc_ids(db, 'WebUser'), | ||
iter_all_doc_ids(db, 'CommCareUser')) | ||
iter_update(db, _update_user, with_progress_bar(all_ids, count), verbose=True) | ||
def handle(self, *args, **options): | ||
do_migration() | ||
|
||
|
||
@once_off_migration("rm_couch_user_data") | ||
def do_migration(): | ||
db = CommCareUser.get_db() | ||
count = (get_doc_count_by_type(db, 'WebUser') | ||
+ get_doc_count_by_type(db, 'CommCareUser')) | ||
all_ids = chain(iter_all_doc_ids(db, 'WebUser'), | ||
iter_all_doc_ids(db, 'CommCareUser')) | ||
iter_update(db, _update_user, with_progress_bar(all_ids, count), verbose=True) | ||
|
||
|
||
def _update_user(user_doc): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this.