Skip to content

Commit

Permalink
Merge pull request #12 from daxxi13/patch-2
Browse files Browse the repository at this point in the history
fix issue #11
  • Loading branch information
Fmstrat authored Sep 3, 2019
2 parents 2205331 + ddb40a6 commit bd98c61
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions plex-db-sync
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function checkForDBs() {
if [ "${DEBUG}" == "true" ]; then
echoD "version db1: ${VPLEXDB1} db2: ${VPLEXDB2}"
fi
if [ [ "${VPLEXDB1}" != "${VPLEXDB2}" ]; then
if [ "${VPLEXDB1}" != "${VPLEXDB2}" ]; then
echoD "Versions of plex databases not equal"
exit
fi
Expand Down Expand Up @@ -160,14 +160,12 @@ function getIgnore() {
}

function createTmpDB() {
sqlite3 "${PLEXDB1}" ".schema metadata_item_settings"|grep CREATE\ TABLE |sed -e 's,CREATE TABLE IF NOT EXISTS "metadata_item_settings",CREATE TABLE IF NOT EXISTS "metadata_item_settings1",g'| sqlite3 "${TMPDB}"
sqlite3 "${PLEXDB1}" ".schema metadata_item_settings"|grep CREATE\ TABLE |sed -e 's,CREATE TABLE IF NOT EXISTS "metadata_item_settings",CREATE TABLE IF NOT EXISTS "metadata_item_settings2",g'| sqlite3 "${TMPDB}"
sqlite3 "${PLEXDB1}" ".schema metadata_items"|grep CREATE\ TABLE |sed -e 's,CREATE TABLE IF NOT EXISTS "metadata_items",CREATE TABLE IF NOT EXISTS "metadata_items1",g'| sqlite3 "${TMPDB}"
sqlite3 "${PLEXDB1}" ".schema metadata_items"|grep CREATE\ TABLE |sed -e 's,CREATE TABLE IF NOT EXISTS "metadata_items",CREATE TABLE IF NOT EXISTS "metadata_items2",g'| sqlite3 "${TMPDB}"
sqlite3 "${PLEXDB1}" ".schema taggings"|grep CREATE\ TABLE |sed -e 's,CREATE TABLE IF NOT EXISTS "taggings",CREATE TABLE IF NOT EXISTS "etadata_taggings1",g'| sqlite3 "${TMPDB}"
sqlite3 "${PLEXDB1}" ".schema taggings"|grep CREATE\ TABLE |sed -e 's,CREATE TABLE IF NOT EXISTS "taggings",CREATE TABLE IF NOT EXISTS "taggings2",g'| sqlite3 "${TMPDB}"
sqlite3 "${PLEXDB1}" ".schema tags"|grep CREATE\ TABLE |sed -e 's,CREATE TABLE IF NOT EXISTS "tags",CREATE TABLE IF NOT EXISTS "tags1",g'| sqlite3 "${TMPDB}"
sqlite3 "${PLEXDB1}" ".schema tags"|grep CREATE\ TABLE |sed -e 's,CREATE TABLE IF NOT EXISTS "tags",CREATE TABLE IF NOT EXISTS "tags2",g'| sqlite3 "${TMPDB}"
TablesTmpDB=(metadata_item_settings metadata_items taggings tags)
for TableTmpDB in ${TablesTmpDB[*]}
do
sqlite3 "${PLEXDB1}" "select sql from sqlite_master where name = '${TableTmpDB}'" | sed -e "s,${TableTmpDB},${TableTmpDB}1,g" | sqlite3 "${TMPDB}"
sqlite3 "${PLEXDB1}" "select sql from sqlite_master where name = '${TableTmpDB}'" | sed -e "s,${TableTmpDB},${TableTmpDB}2,g" | sqlite3 "${TMPDB}"
done
echo "attach '${PLEXDB1}' as plexdb; attach '${TMPDB}' as tmpdb; insert into tmpdb.metadata_item_settings1 select * from plexdb.metadata_item_settings; insert into tmpdb.metadata_items1 select * from plexdb.metadata_items; insert into tmpdb.taggings1 select * from plexdb.taggings; insert into tmpdb.tags1 select * from plexdb.tags;" | sqlite3
echo "attach '${PLEXDB2}' as plexdb; attach '${TMPDB}' as tmpdb; insert into tmpdb.metadata_item_settings2 select * from plexdb.metadata_item_settings; insert into tmpdb.metadata_items2 select * from plexdb.metadata_items; insert into tmpdb.taggings2 select * from plexdb.taggings; insert into tmpdb.tags2 select * from plexdb.tags;" | sqlite3
}
Expand Down

0 comments on commit bd98c61

Please sign in to comment.