Create table indices after table upgrades
This commit is contained in:
@@ -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.
|
||||||
@@ -1136,6 +1130,14 @@ def dbcheck():
|
|||||||
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()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user