-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdb-delete-one.sh
More file actions
executable file
·55 lines (48 loc) · 1.35 KB
/
db-delete-one.sh
File metadata and controls
executable file
·55 lines (48 loc) · 1.35 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
# delete an sdbid from sdb, use this when an import fails for some
# reason (i.e. is left in the "import_failed" table in sdb)
# check we were given an sdbid
if [[ $1 =~ ^sdb-v[0-9]-[0-9]{6}\.[0-9]{2}[+-][0-9]{6}\.[0-9] ]]
then
echo "$1 ok"
else
echo "$1 not an sdbid"
exit
fi
db=sdb
db_samp=sdb_samples
db_res=sdb_results
# samples
mysql $db_samp -N -e "SHOW TABLES;" | while read t
do
st="UPDATE $t SET sdbid = NULL WHERE sdbid = '$1';"
echo $st
mysql $db_samp -N -e "$st"
done
# remove other sdbids with the same xids as the sdbid we're deleting
mysql $db -N -e "SELECT xid FROM xids WHERE sdbid = '$1';" | while read x
do
echo "xid: $x"
mysql $db -N -e "SELECT DISTINCT sdbid FROM xids WHERE xid = '$x' AND sdbid != '$1';" | while read s
do
# do this first to avoid infinite loop
st="DELETE FROM xids WHERE sdbid = '$s';"
echo $st
mysql $db -N -e "$st"
./db-delete-one.sh $s
done
done
# sbd tables
for t in twomass akari_irc allwise apass catwise denis gaia_dr2 galex import_failed projects sdss12 seip simbad spectra tyc2 xids sdb_pm;
do
st="DELETE FROM $t WHERE sdbid = '$1';"
echo $st
mysql $db -N -e "$st"
done
# results
mysql $db_res -N -e "SHOW TABLES;" | while read t
do
st="DELETE FROM $t WHERE id = '$1';"
echo $st
mysql $db_res -N -e "$st"
done