Add script to delete member addresses from database
This commit is contained in:
parent
e263a6847f
commit
06fffca262
40
apiserver/delete_addresses.py
Executable file
40
apiserver/delete_addresses.py
Executable 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.')
|
Loading…
Reference in New Issue
Block a user