Add script to delete member addresses from database

This commit is contained in:
Tanner Collin 2020-09-27 04:02:07 +00:00
parent e263a6847f
commit 06fffca262

40
apiserver/delete_addresses.py Executable file
View File

@ -0,0 +1,40 @@
import django, sys, os
os.environ['DJANGO_SETTINGS_MODULE'] = 'apiserver.settings'
django.setup()
from apiserver.api import models
print('Deleting member object addresses...')
result = models.Member.objects.update(
street_address='',
postal_code='',
city='',
)
print(result, 'rows affected')
print()
print('Scrubbing history...')
result = models.Member.history.update(
street_address='',
postal_code='',
city='',
)
print(result, 'rows affected')
print()
print('Deleting historical changes...')
address_fields = ['street_address', 'postal_code', 'city']
result = models.HistoryChange.objects.filter(field__in=address_fields).update(
old='',
new='',
)
print(result, 'rows affected')
print()
print('Done.')