Skip to content

Commit a3bc062

Browse files
committed
Added cleanout of local tables missing from db dump (assuming they have been created by migrations) and added new switches --no-load and --no-zap to docker/updatedb
- Legacy-Id: 17924
1 parent f9ad234 commit a3bc062

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

docker/updatedb

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
# -*- indent-with-tabs: 1 -*-
23

34
version=0.10
45
program=${0##*/}
@@ -69,11 +70,12 @@ trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)";
6970
# Option parsing
7071

7172
# Options
72-
shortopts=DhqvV
73-
longopts=no-download,help,quiet,verbose,version
73+
shortopts=DLZhqvV
74+
longopts=no-download,no-load,no-zap,help,quiet,verbose,version
7475

7576
LOAD=1
7677
DOWNLOAD=1
78+
DROP=1
7779
QUIET=""
7880

7981
if [ "$(uname)" = "Linux" ]; then
@@ -91,12 +93,13 @@ fi
9193

9294
while true ; do
9395
case "$1" in
94-
-d| --download) LOAD="";; # Only download
95-
-D| --no-download) DOWNLOAD="";; # Don't download, use existing file
96-
-h| --help) usage; exit;; # Show this help, then exit
97-
-q| --quiet) QUIET="-q";; # Don't show progress
98-
-v| --verbose) VERBOSE=1;; # Be more talkative
99-
-V| --version) version; exit;; # Show program version, then exit
96+
-D| --no-download) DOWNLOAD="";; #Don't download, use existing file
97+
-L| --no-load) LOAD=""; ;; # Don't load the database
98+
-Z| --no-zap) DROP="";; # Don't drop new tables
99+
-h| --help) usage; exit;; # Show this help, then exit
100+
-q| --quiet) QUIET="-q";; # Don't show progress
101+
-v| --verbose) VERBOSE=1;; # Be more talkative
102+
-V| --version) version; exit;; # Show program version, then exit
100103
--) shift; break;;
101104
*) die "Internal error, inconsistent option specification: '$1'";;
102105
esac
@@ -143,5 +146,13 @@ if [ "$LOAD" ]; then
143146
| sed -e 's/ENGINE=MyISAM/ENGINE=InnoDB/' \
144147
| $parent/ietf/manage.py dbshell
145148
fi
149+
146150
fi
147151

152+
if [ "$DROP" ]; then
153+
echo "Dropping tables not in the dump (so migrations can succeed) ..."
154+
diff <(zcat $DATADIR/ietf_utf8.sql.gz | grep '^DROP TABLE IF EXISTS' | tr -d '`;' | field 5) \
155+
<($parent/ietf/manage.py dbshell <<< 'show tables;' | tail -n +2) \
156+
| grep '^>' | awk '{print "drop table if exists", $2, ";";}' \
157+
| tee /dev/stderr | $parent/ietf/manage.py dbshell
158+
fi

0 commit comments

Comments
 (0)