mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 23:42:37 -07:00
Clean up lookup table unique constraints on start up
This commit is contained in:
parent
6e6de11aaa
commit
85eaed57e0
1 changed files with 25 additions and 9 deletions
|
@ -2433,27 +2433,43 @@ def dbcheck():
|
||||||
'ALTER TABLE exports ADD COLUMN total_items INTEGER DEFAULT 0'
|
'ALTER TABLE exports ADD COLUMN total_items INTEGER DEFAULT 0'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Upgrade image_hash_lookup table from earlier versions
|
# Fix unique constraints
|
||||||
|
try:
|
||||||
|
c_db.execute('DELETE FROM tvmaze_lookup '
|
||||||
|
'WHERE id NOT IN (SELECT MIN(id) FROM tvmaze_lookup GROUP BY rating_key)')
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
c_db.execute('DELETE FROM themoviedb_lookup '
|
||||||
|
'WHERE id NOT IN (SELECT MIN(id) FROM themoviedb_lookup GROUP BY rating_key)')
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
c_db.execute('DELETE FROM musicbrainz_lookup '
|
||||||
|
'WHERE id NOT IN (SELECT MIN(id) FROM musicbrainz_lookup GROUP BY rating_key)')
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
c_db.execute('DELETE FROM image_hash_lookup '
|
c_db.execute('DELETE FROM image_hash_lookup '
|
||||||
'WHERE id NOT IN (SELECT MIN(id) FROM image_hash_lookup GROUP BY img_hash)')
|
'WHERE id NOT IN (SELECT MIN(id) FROM image_hash_lookup GROUP BY img_hash)')
|
||||||
except sqlite3.OperationalError:
|
except sqlite3.OperationalError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Upgrade imgur_lookup table from earlier versions
|
|
||||||
try:
|
|
||||||
c_db.execute('DELETE FROM imgur_lookup '
|
|
||||||
'WHERE id NOT IN (SELECT MIN(id) FROM imgur_lookup GROUP BY img_hash)')
|
|
||||||
except sqlite3.OperationalError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Upgrade cloudinary_lookup table from earlier versions
|
|
||||||
try:
|
try:
|
||||||
c_db.execute('DELETE FROM cloudinary_lookup '
|
c_db.execute('DELETE FROM cloudinary_lookup '
|
||||||
'WHERE id NOT IN (SELECT MIN(id) FROM cloudinary_lookup GROUP BY img_hash)')
|
'WHERE id NOT IN (SELECT MIN(id) FROM cloudinary_lookup GROUP BY img_hash)')
|
||||||
except sqlite3.OperationalError:
|
except sqlite3.OperationalError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
c_db.execute('DELETE FROM imgur_lookup '
|
||||||
|
'WHERE id NOT IN (SELECT MIN(id) FROM imgur_lookup GROUP BY img_hash)')
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
pass
|
||||||
|
|
||||||
# Add "Local" user to database as default unauthenticated user.
|
# Add "Local" user to database as default unauthenticated user.
|
||||||
result = c_db.execute('SELECT id FROM users WHERE username = "Local"')
|
result = c_db.execute('SELECT id FROM users WHERE username = "Local"')
|
||||||
if not result.fetchone():
|
if not result.fetchone():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue