Skip to content

Commit f06457b

Browse files
committed
add scripts/dbdiff.sh to compare sqlite3 databases (defaults to srs.db)
1 parent 5cb1519 commit f06457b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

scripts/dbdiff.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
if [ "$1" = "-h" ]; then
4+
echo "usage: $0 [-h] [database] [sha1] [sha2]"
5+
echo " -h show this help"
6+
echo " database databases to compare (defaults to resources/srs.db"
7+
echo " sha1 sha of previous state (defaults to HEAD^)"
8+
echo " sha2 sha of next state (defaults to HEAD)"
9+
exit 1
10+
fi
11+
12+
set -e
13+
14+
db=${1:-resources/srs.db}
15+
prev=${2:-HEAD^}
16+
next=${3:-HEAD}
17+
18+
echo "db:$db prev:$prev next:$next"
19+
20+
git cat-file blob $prev:resources/srs.db >/tmp/prev.db
21+
git cat-file blob $next:resources/srs.db >/tmp/next.db
22+
23+
sqlite3 /tmp/prev.db .dump >/tmp/prev.sql
24+
sqlite3 /tmp/next.db .dump >/tmp/curr.sql
25+
26+
diff -u /tmp/prev.sql /tmp/curr.sql
27+
28+
rm /tmp/prev.db /tmp/next.db /tmp/prev.sql /tmp/curr.sql

0 commit comments

Comments
 (0)