Better logic when upgrading from the old extras format to the new

This commit is contained in:
rembo10
2012-08-19 13:44:16 +05:30
parent d1b5d2a960
commit ecb5395c22
2 changed files with 8 additions and 4 deletions

View File

@@ -887,12 +887,15 @@ def dbcheck():
try:
c.execute('SELECT Extras from artists')
except sqlite3.OperationalError:
# Need to update some stuff when people are upgrading and have the 'INCLUDE_EXTRAS' options selected
c.execute('ALTER TABLE artists ADD COLUMN Extras TEXT DEFAULT NULL')
# Need to update some stuff when people are upgrading and have 'include extras' set globally/for an artist
if INCLUDE_EXTRAS:
EXTRAS = "1,2,3,4,5,6,7,8"
c.execute('ALTER TABLE artists ADD COLUMN Extras TEXT DEFAULT "1,2,3,4,5,6,7,8"')
else:
c.execute('ALTER TABLE artists ADD COLUMN Extras TEXT DEFAULT NULL')
logger.info("Copying over current artist IncludeExtras information")
artists = c.execute('SELECT ArtistID, IncludeExtras from artists').fetchall()
for artist in artists:
if artist['IncludeExtras']:
c.execute('INSERT into artists Extras="1,2,3,4,5,6,7,8" WHERE ArtistID=' + artist['ArtistID'])
conn.commit()
c.close()

View File

@@ -230,6 +230,7 @@ def getArtist(artistid, extrasonly=False):
})
# See if we need to grab extras. Artist specific extras take precedence over global option
# Global options are set when adding a new artist
myDB = db.DBConnection()
try: