forked from int-brain-lab/IBL-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete_shadow_tables_for_updates.py
33 lines (26 loc) · 1.23 KB
/
delete_shadow_tables_for_updates.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import datajoint as dj
from ibl_pipeline.ingest import alyxraw, data
from ibl_pipeline.ingest import action, acquisition
dj.config['safemode'] = False
# delete alyxraw for data.filerecord if exists = 0
print('Deleting alyxraw entries corresponding to file records...')
file_record_fields = alyxraw.AlyxRaw.Field & \
'fname = "exists"' & 'fvalue = "False"'
for key in file_record_fields:
(alyxraw.AlyxRaw.Field & key).delete_quick()
# delete water tables and related alyxraw entries
print('Deleting alyxraw entries of shadow weighing and water tables...')
(alyxraw.AlyxRaw & 'model in ("actions.weighing", "actions.waterrestriction", \
"actions.wateradministration")').delete()
# delete the lab, user, user_history, death_date,
# and caging field of the subject
print('Deleting subject fields lab, user, user_hisotry and death date...')
subject_fields = alyxraw.AlyxRaw.Field & \
(alyxraw.AlyxRaw & 'model="subjects.subject"') & \
'fname in ("lab", "death_date", "responsible_user", "json")'
subject_fields.delete_quick()
# delete some shadow membership tables
print('Deleting shadow membership tables...')
action.WaterRestrictionProcedure.delete()
action.WaterRestrictionUser.delete()
acquisition.WaterAdministrationSession.delete()