diff --git a/docs/clean-up-prod-db-for-import.md b/docs/clean-up-prod-db-for-import.md index 900769be..d68942ba 100644 --- a/docs/clean-up-prod-db-for-import.md +++ b/docs/clean-up-prod-db-for-import.md @@ -1,3 +1,13 @@ +# Update prepreprod Database Contents + + +This document describes the process to import data from a Production database to a preprod database, whith +the removal of all users and their content that are not admin users. +Checkout the commit that is deployed on your target preprod app. + + +``` + Download latest backup from Heroku ``` @@ -13,12 +23,17 @@ Load backup locally Remove all users that are not admin users, also their created contents +```bash +pip install shell_plus --upgrade +python mangage.py migrate +python manage.py shell ``` + +```python Objective.objects.exclude(owner=None).delete() Comment.objects.all().delete() Assignment.objects.exclude(owner=None).exclude(owner__username="guru").delete() - -User.objects.filter(is_superuser=False).delete() +User.objects.filter(is_superuser=False).exclude(username="mia.teacher@getnada.com").delete() ``` Make local dump of database