stages/user_write: add migration that removes unintended data

This commit is contained in:
Jens Langhammer 2020-09-18 18:58:07 +02:00
parent dfe093b2b9
commit d4d026bf6a
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
# Generated by Django 3.1.1 on 2020-09-18 16:53
from django.apps.registry import Apps
from django.db import migrations
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
def remove_unintended_attributes(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
db_alias = schema_editor.connection.alias
User = apps.get_model("passbook_core", "User")
for user in User.objects.using(db_alias).all():
if "password_repeat" in user.attributes:
del user.attributes["password_repeat"]
if "password" in user.attributes:
del user.attributes["password"]
user.save()
class Migration(migrations.Migration):
dependencies = [
("passbook_stages_user_write", "0001_initial"),
]
operations = [
migrations.RunPython(remove_unintended_attributes),
]