Adjusted merge scripts for fts tables.

This commit is contained in:
Michael Herzberg 2017-07-13 14:43:37 +01:00
parent 26bddde328
commit a901fa30bb
2 changed files with 22 additions and 4 deletions

View File

@ -16,5 +16,4 @@ override_vars
set -u
find $DBDIR -name "*.sqlite" -exec bash -c "sqlite3 {} .schema | sqlite3 $OUTDBPATH" \; -quit
find $DBDIR -name "*.sqlite" -exec "$EXTENSIONCRAWLERDIR/scripts/merge_dbs.sh" "{}" "$OUTDBPATH" \;

View File

@ -7,11 +7,30 @@ if [ -z $FROM_DB ] || ! [ -f $FROM_DB ]; then
exit 1
fi
if [ -z $TO_DB ] || ! [ -f $TO_DB ]; then
echo "destination db not provided or does not exist"
if [ -z $TO_DB ]; then
echo "destination db not provided"
exit 1
fi
if ! [ -f $TO_DB ]; then
echo "Creating $TO_DB ..."
sqlite3 $FROM_DB .schema | grep -Eiv \
-e "^CREATE TABLE IF NOT EXISTS (\"|')?[a-z]+_content(\"|')?\(" \
-e "^CREATE TABLE IF NOT EXISTS (\"|')?[a-z]+_docsize(\"|')?\(" \
-e "^CREATE TABLE IF NOT EXISTS (\"|')?[a-z]+_segments(\"|')?\(" \
-e "^CREATE TABLE IF NOT EXISTS (\"|')?[a-z]+_stat(\"|')?\(" \
-e "^CREATE TABLE IF NOT EXISTS (\"|')?[a-z]+_segdir(\"|')?\(" \
| sqlite3 $TO_DB
fi
echo "Merging $FROM_DB into $TO_DB..."
sqlite3 $FROM_DB .dump | grep -v "^CREATE TABLE" | sqlite3 $TO_DB
sqlite3 $FROM_DB .dump | grep -Eiv \
-e "^CREATE TABLE" \
-e "^INSERT INTO (\"|')?sqlite_master(\"|')?" \
-e "^INSERT INTO (\"|')?[a-z]+_segments(\"|')? " \
-e "^INSERT INTO (\"|')?[a-z]+_segdir(\"|')? " \
-e "^INSERT INTO (\"|')?[a-z]+_docsize(\"|')? " \
-e "^INSERT INTO (\"|')?[a-z]+_stat(\"|')? " \
| sed -r "s/^INSERT INTO ([a-z]+)_content VALUES\([[:digit:]]+,/INSERT INTO \1 VALUES(/I" \
| sqlite3 $TO_DB