mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 12:59:42 -07:00
Create table indices after table upgrades
This commit is contained in:
parent
0c62a83145
commit
81dca01302
1 changed files with 12 additions and 10 deletions
|
@ -547,9 +547,6 @@ def dbcheck():
|
||||||
'rating_key INTEGER, thetvdb_id INTEGER, imdb_id TEXT, '
|
'rating_key INTEGER, thetvdb_id INTEGER, imdb_id TEXT, '
|
||||||
'tvmaze_id INTEGER, tvmaze_url TEXT, tvmaze_json TEXT)'
|
'tvmaze_id INTEGER, tvmaze_url TEXT, tvmaze_json TEXT)'
|
||||||
)
|
)
|
||||||
c_db.execute(
|
|
||||||
'CREATE UNIQUE INDEX IF NOT EXISTS idx_tvmaze_lookup ON tvmaze_lookup (rating_key)'
|
|
||||||
)
|
|
||||||
|
|
||||||
# themoviedb_lookup table :: This table keeps record of the TheMovieDB lookups
|
# themoviedb_lookup table :: This table keeps record of the TheMovieDB lookups
|
||||||
c_db.execute(
|
c_db.execute(
|
||||||
|
@ -557,9 +554,6 @@ def dbcheck():
|
||||||
'rating_key INTEGER, thetvdb_id INTEGER, imdb_id TEXT, '
|
'rating_key INTEGER, thetvdb_id INTEGER, imdb_id TEXT, '
|
||||||
'themoviedb_id INTEGER, themoviedb_url TEXT, themoviedb_json TEXT)'
|
'themoviedb_id INTEGER, themoviedb_url TEXT, themoviedb_json TEXT)'
|
||||||
)
|
)
|
||||||
c_db.execute(
|
|
||||||
'CREATE UNIQUE INDEX IF NOT EXISTS idx_themoviedb_lookup ON themoviedb_lookup (rating_key)'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Upgrade sessions table from earlier versions
|
# Upgrade sessions table from earlier versions
|
||||||
try:
|
try:
|
||||||
|
@ -1109,10 +1103,10 @@ def dbcheck():
|
||||||
'ALTER TABLE tvmaze_lookup ADD COLUMN rating_key INTEGER'
|
'ALTER TABLE tvmaze_lookup ADD COLUMN rating_key INTEGER'
|
||||||
)
|
)
|
||||||
c_db.execute(
|
c_db.execute(
|
||||||
'DROP INDEX idx_tvmaze_lookup_thetvdb_id'
|
'DROP INDEX IF EXISTS idx_tvmaze_lookup_thetvdb_id'
|
||||||
)
|
)
|
||||||
c_db.execute(
|
c_db.execute(
|
||||||
'DROP INDEX idx_tvmaze_lookup_imdb_id'
|
'DROP INDEX IF EXISTS idx_tvmaze_lookup_imdb_id'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Upgrade themoviedb_lookup table from earlier versions
|
# Upgrade themoviedb_lookup table from earlier versions
|
||||||
|
@ -1124,10 +1118,10 @@ def dbcheck():
|
||||||
'ALTER TABLE themoviedb_lookup ADD COLUMN rating_key INTEGER'
|
'ALTER TABLE themoviedb_lookup ADD COLUMN rating_key INTEGER'
|
||||||
)
|
)
|
||||||
c_db.execute(
|
c_db.execute(
|
||||||
'DROP INDEX idx_themoviedb_lookup_thetvdb_id'
|
'DROP INDEX IF EXISTS idx_themoviedb_lookup_thetvdb_id'
|
||||||
)
|
)
|
||||||
c_db.execute(
|
c_db.execute(
|
||||||
'DROP INDEX idx_themoviedb_lookup_imdb_id'
|
'DROP INDEX IF EXISTS idx_themoviedb_lookup_imdb_id'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add "Local" user to database as default unauthenticated user.
|
# Add "Local" user to database as default unauthenticated user.
|
||||||
|
@ -1135,6 +1129,14 @@ def dbcheck():
|
||||||
if not result.fetchone():
|
if not result.fetchone():
|
||||||
logger.debug(u"User 'Local' does not exist. Adding user.")
|
logger.debug(u"User 'Local' does not exist. Adding user.")
|
||||||
c_db.execute('INSERT INTO users (user_id, username) VALUES (0, "Local")')
|
c_db.execute('INSERT INTO users (user_id, username) VALUES (0, "Local")')
|
||||||
|
|
||||||
|
# Create table indices
|
||||||
|
c_db.execute(
|
||||||
|
'CREATE UNIQUE INDEX IF NOT EXISTS idx_tvmaze_lookup ON tvmaze_lookup (rating_key)'
|
||||||
|
)
|
||||||
|
c_db.execute(
|
||||||
|
'CREATE UNIQUE INDEX IF NOT EXISTS idx_themoviedb_lookup ON themoviedb_lookup (rating_key)'
|
||||||
|
)
|
||||||
|
|
||||||
conn_db.commit()
|
conn_db.commit()
|
||||||
c_db.close()
|
c_db.close()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue