-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34805 from dimagi/es/user-data-prep
Remove user data from couch user model
- Loading branch information
Showing
18 changed files
with
177 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
corehq/apps/users/management/commands/populate_sql_user_data.py
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
corehq/apps/users/management/commands/rm_couch_user_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 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, | ||
iter_all_doc_ids, | ||
) | ||
from corehq.util.couch import DocUpdate, iter_update | ||
from corehq.util.log import with_progress_bar | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Remove now-stale CouchUser.user_data field" | ||
|
||
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): | ||
couch_data = user_doc.pop('user_data', ...) | ||
if couch_data is not ...: | ||
return DocUpdate(user_doc) |
Oops, something went wrong.