Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cosmetics: align code

  • Loading branch information...
commit 51bc6453742521fab2e058a92d7deb01a1dcbef3 1 parent 6107ee4
Jonathan Marshall authored
View
124 xbmc/TextureDatabase.cpp
@@ -74,70 +74,70 @@ bool CTextureDatabase::CreateTables()
bool CTextureDatabase::UpdateOldVersion(int version)
{
- if (version < 7)
- { // update all old thumb://foo urls to image://foo?size=thumb
- m_pDS->query("select id,texture from path where texture like 'thumb://%'");
- while (!m_pDS->eof())
- {
- unsigned int id = m_pDS->fv(0).get_asInt();
- CURL url(m_pDS->fv(1).get_asString());
- m_pDS2->exec(PrepareSQL("update path set texture='image://%s?size=thumb' where id=%u", url.GetHostName().c_str(), id));
- m_pDS->next();
- }
- m_pDS->query("select id, url from texture where url like 'thumb://%'");
- while (!m_pDS->eof())
- {
- unsigned int id = m_pDS->fv(0).get_asInt();
- CURL url(m_pDS->fv(1).get_asString());
- m_pDS2->exec(PrepareSQL("update texture set url='image://%s?size=thumb', urlhash=0 where id=%u", url.GetHostName().c_str(), id));
- m_pDS->next();
- }
- m_pDS->close();
- }
- if (version < 8)
- { // get rid of old cached thumbs as they were previously set to the cached thumb name instead of the source thumb
- m_pDS->exec("delete from path");
- }
- if (version < 9)
- { // get rid of the old path table and add the type column
- m_pDS->dropIndex("path", "idxPath");
- m_pDS->exec("DROP TABLE path");
- m_pDS->exec("CREATE TABLE path (id integer primary key, urlhash integer, url text, type text, texture text)\n");
- m_pDS->exec("CREATE INDEX idxPath ON path(urlhash, type)");
- }
- if (version < 10)
- { // get rid of urlhash in both tables...
- m_pDS->dropIndex("path", "idxPath");
- m_pDS->exec("DROP TABLE path");
- m_pDS->exec("CREATE TABLE path (id integer primary key, url text, type text, texture text)\n");
- m_pDS->exec("CREATE INDEX idxPath ON path(url, type)");
-
- m_pDS->dropIndex("texture", "idxTexture");
- m_pDS->exec("CREATE TEMPORARY TABLE texture_backup(id,url,cachedurl,usecount,lastusetime,imagehash,lasthashcheck)");
- m_pDS->exec("INSERT INTO texture_backup SELECT id,url,cachedurl,usecount,lastusetime,imagehash,lasthashcheck FROM texture");
- m_pDS->exec("DROP TABLE texture");
- m_pDS->exec("CREATE TABLE texture (id integer primary key, url text, cachedurl text, usecount integer, lastusetime text, imagehash text, lasthashcheck text)");
- m_pDS->exec("CREATE INDEX idxTexture ON texture(url)");
- m_pDS->exec("INSERT INTO texture SELECT * FROM texture_backup");
- m_pDS->exec("DROP TABLE texture_backup");
- }
- if (version < 11)
- { // get rid of cached URLs that don't have the correct extension
- m_pDS->exec("DELETE FROM texture WHERE SUBSTR(cachedUrl,-4,4) NOT IN ('.jpg', '.png')");
- }
- if (version < 12)
- { // create new sizes table and move usecount info to it.
- m_pDS->exec("DROP TABLE texture");
- m_pDS->exec("CREATE TABLE texture (id integer primary key, url text, cachedurl text, imagehash text, lasthashcheck text)");
- m_pDS->exec("CREATE INDEX idxTexture ON texture(url)");
- m_pDS->exec("CREATE TABLE sizes (idtexture integer, size integer, width integer, height integer, usecount integer, lastusetime text)");
- m_pDS->exec("CREATE INDEX idxSize ON sizes(idtexture, size)");
- m_pDS->exec("CREATE TRIGGER textureDelete AFTER delete ON texture FOR EACH ROW BEGIN delete from sizes where sizes.idtexture=old.id; END");
+ if (version < 7)
+ { // update all old thumb://foo urls to image://foo?size=thumb
+ m_pDS->query("select id,texture from path where texture like 'thumb://%'");
+ while (!m_pDS->eof())
+ {
+ unsigned int id = m_pDS->fv(0).get_asInt();
+ CURL url(m_pDS->fv(1).get_asString());
+ m_pDS2->exec(PrepareSQL("update path set texture='image://%s?size=thumb' where id=%u", url.GetHostName().c_str(), id));
+ m_pDS->next();
}
- if (version < 13)
- { // index for updateusecount
- m_pDS->exec("CREATE INDEX idxSize2 ON sizes(idtexture, width, height)");
+ m_pDS->query("select id, url from texture where url like 'thumb://%'");
+ while (!m_pDS->eof())
+ {
+ unsigned int id = m_pDS->fv(0).get_asInt();
+ CURL url(m_pDS->fv(1).get_asString());
+ m_pDS2->exec(PrepareSQL("update texture set url='image://%s?size=thumb', urlhash=0 where id=%u", url.GetHostName().c_str(), id));
+ m_pDS->next();
}
+ m_pDS->close();
+ }
+ if (version < 8)
+ { // get rid of old cached thumbs as they were previously set to the cached thumb name instead of the source thumb
+ m_pDS->exec("delete from path");
+ }
+ if (version < 9)
+ { // get rid of the old path table and add the type column
+ m_pDS->dropIndex("path", "idxPath");
+ m_pDS->exec("DROP TABLE path");
+ m_pDS->exec("CREATE TABLE path (id integer primary key, urlhash integer, url text, type text, texture text)\n");
+ m_pDS->exec("CREATE INDEX idxPath ON path(urlhash, type)");
+ }
+ if (version < 10)
+ { // get rid of urlhash in both tables...
+ m_pDS->dropIndex("path", "idxPath");
+ m_pDS->exec("DROP TABLE path");
+ m_pDS->exec("CREATE TABLE path (id integer primary key, url text, type text, texture text)\n");
+ m_pDS->exec("CREATE INDEX idxPath ON path(url, type)");
+
+ m_pDS->dropIndex("texture", "idxTexture");
+ m_pDS->exec("CREATE TEMPORARY TABLE texture_backup(id,url,cachedurl,usecount,lastusetime,imagehash,lasthashcheck)");
+ m_pDS->exec("INSERT INTO texture_backup SELECT id,url,cachedurl,usecount,lastusetime,imagehash,lasthashcheck FROM texture");
+ m_pDS->exec("DROP TABLE texture");
+ m_pDS->exec("CREATE TABLE texture (id integer primary key, url text, cachedurl text, usecount integer, lastusetime text, imagehash text, lasthashcheck text)");
+ m_pDS->exec("CREATE INDEX idxTexture ON texture(url)");
+ m_pDS->exec("INSERT INTO texture SELECT * FROM texture_backup");
+ m_pDS->exec("DROP TABLE texture_backup");
+ }
+ if (version < 11)
+ { // get rid of cached URLs that don't have the correct extension
+ m_pDS->exec("DELETE FROM texture WHERE SUBSTR(cachedUrl,-4,4) NOT IN ('.jpg', '.png')");
+ }
+ if (version < 12)
+ { // create new sizes table and move usecount info to it.
+ m_pDS->exec("DROP TABLE texture");
+ m_pDS->exec("CREATE TABLE texture (id integer primary key, url text, cachedurl text, imagehash text, lasthashcheck text)");
+ m_pDS->exec("CREATE INDEX idxTexture ON texture(url)");
+ m_pDS->exec("CREATE TABLE sizes (idtexture integer, size integer, width integer, height integer, usecount integer, lastusetime text)");
+ m_pDS->exec("CREATE INDEX idxSize ON sizes(idtexture, size)");
+ m_pDS->exec("CREATE TRIGGER textureDelete AFTER delete ON texture FOR EACH ROW BEGIN delete from sizes where sizes.idtexture=old.id; END");
+ }
+ if (version < 13)
+ { // index for updateusecount
+ m_pDS->exec("CREATE INDEX idxSize2 ON sizes(idtexture, width, height)");
+ }
return true;
}
View
28 xbmc/addons/AddonDatabase.cpp
@@ -101,20 +101,20 @@ bool CAddonDatabase::CreateTables()
bool CAddonDatabase::UpdateOldVersion(int version)
{
- if (version < 13)
- {
- m_pDS->exec("CREATE TABLE dependencies (id integer, addon text, version text, optional boolean)\n");
- m_pDS->exec("CREATE INDEX idxDependencies ON dependencies(id)");
- }
- if (version < 14)
- {
- m_pDS->exec("ALTER TABLE addon add minversion text");
- }
- if (version < 15)
- {
- m_pDS->exec("CREATE TABLE blacklist (id integer primary key, addonID text, version text)\n");
- m_pDS->exec("CREATE UNIQUE INDEX idxBlack ON blacklist(addonID)");
- }
+ if (version < 13)
+ {
+ m_pDS->exec("CREATE TABLE dependencies (id integer, addon text, version text, optional boolean)\n");
+ m_pDS->exec("CREATE INDEX idxDependencies ON dependencies(id)");
+ }
+ if (version < 14)
+ {
+ m_pDS->exec("ALTER TABLE addon add minversion text");
+ }
+ if (version < 15)
+ {
+ m_pDS->exec("CREATE TABLE blacklist (id integer primary key, addonID text, version text)\n");
+ m_pDS->exec("CREATE UNIQUE INDEX idxBlack ON blacklist(addonID)");
+ }
return true;
}
View
578 xbmc/music/MusicDatabase.cpp
@@ -3182,341 +3182,341 @@ bool CMusicDatabase::GetSongsNav(const CStdString& strBaseDir, CFileItemList& it
bool CMusicDatabase::UpdateOldVersion(int version)
{
- if (version < 16)
- {
- // only if MySQL is used and default character set is not utf8
- // string data needs to be converted to proper utf8
- CStdString charset = m_pDS->getDatabase()->getDefaultCharset();
- if (!m_sqlite && !charset.empty() && charset != "utf8")
+ if (version < 16)
+ {
+ // only if MySQL is used and default character set is not utf8
+ // string data needs to be converted to proper utf8
+ CStdString charset = m_pDS->getDatabase()->getDefaultCharset();
+ if (!m_sqlite && !charset.empty() && charset != "utf8")
+ {
+ map<CStdString, CStdStringArray> tables;
+ map<CStdString, CStdStringArray>::iterator itt;
+ CStdStringArray::iterator itc;
+
+ //columns that need to be converted
+ CStdStringArray c1;
+ c1.push_back("strAlbum");
+ c1.push_back("strExtraArtists");
+ c1.push_back("strExtraGenres");
+ tables.insert(pair<CStdString, CStdStringArray> ("album", c1));
+
+ CStdStringArray c2;
+ c2.push_back("strExtraGenres");
+ c2.push_back("strMoods");
+ c2.push_back("strStyles");
+ c2.push_back("strThemes");
+ c2.push_back("strReview");
+ c2.push_back("strLabel");
+ tables.insert(pair<CStdString, CStdStringArray> ("albuminfo", c2));
+
+ CStdStringArray c3;
+ c3.push_back("strTitle");
+ tables.insert(pair<CStdString, CStdStringArray> ("albuminfosong", c3));
+
+ CStdStringArray c4;
+ c4.push_back("strArtist");
+ tables.insert(pair<CStdString, CStdStringArray> ("artist", c4));
+
+ CStdStringArray c5;
+ c5.push_back("strBorn");
+ c5.push_back("strFormed");
+ c5.push_back("strGenres");
+ c5.push_back("strMoods");
+ c5.push_back("strStyles");
+ c5.push_back("strInstruments");
+ c5.push_back("strBiography");
+ c5.push_back("strDied");
+ c5.push_back("strDisbanded");
+ c5.push_back("strYearsActive");
+ tables.insert(pair<CStdString, CStdStringArray> ("artistinfo", c5));
+
+ CStdStringArray c6;
+ c6.push_back("strAlbum");
+ tables.insert(pair<CStdString, CStdStringArray> ("discography", c6));
+
+ CStdStringArray c7;
+ c7.push_back("strGenre");
+ tables.insert(pair<CStdString, CStdStringArray> ("genre", c7));
+
+ CStdStringArray c8;
+ c8.push_back("strKaraLyrics");
+ tables.insert(pair<CStdString, CStdStringArray> ("karaokedata", c8));
+
+ CStdStringArray c9;
+ c9.push_back("strTitle");
+ c9.push_back("strFilename");
+ c9.push_back("comment");
+ tables.insert(pair<CStdString, CStdStringArray> ("song", c9));
+
+ CStdStringArray c10;
+ c10.push_back("strPath");
+ tables.insert(pair<CStdString, CStdStringArray> ("path", c10));
+
+ for (itt = tables.begin(); itt != tables.end(); ++itt)
{
- map<CStdString, CStdStringArray> tables;
- map<CStdString, CStdStringArray>::iterator itt;
- CStdStringArray::iterator itc;
-
- //columns that need to be converted
- CStdStringArray c1;
- c1.push_back("strAlbum");
- c1.push_back("strExtraArtists");
- c1.push_back("strExtraGenres");
- tables.insert(pair<CStdString, CStdStringArray> ("album", c1));
-
- CStdStringArray c2;
- c2.push_back("strExtraGenres");
- c2.push_back("strMoods");
- c2.push_back("strStyles");
- c2.push_back("strThemes");
- c2.push_back("strReview");
- c2.push_back("strLabel");
- tables.insert(pair<CStdString, CStdStringArray> ("albuminfo", c2));
-
- CStdStringArray c3;
- c3.push_back("strTitle");
- tables.insert(pair<CStdString, CStdStringArray> ("albuminfosong", c3));
-
- CStdStringArray c4;
- c4.push_back("strArtist");
- tables.insert(pair<CStdString, CStdStringArray> ("artist", c4));
-
- CStdStringArray c5;
- c5.push_back("strBorn");
- c5.push_back("strFormed");
- c5.push_back("strGenres");
- c5.push_back("strMoods");
- c5.push_back("strStyles");
- c5.push_back("strInstruments");
- c5.push_back("strBiography");
- c5.push_back("strDied");
- c5.push_back("strDisbanded");
- c5.push_back("strYearsActive");
- tables.insert(pair<CStdString, CStdStringArray> ("artistinfo", c5));
-
- CStdStringArray c6;
- c6.push_back("strAlbum");
- tables.insert(pair<CStdString, CStdStringArray> ("discography", c6));
-
- CStdStringArray c7;
- c7.push_back("strGenre");
- tables.insert(pair<CStdString, CStdStringArray> ("genre", c7));
-
- CStdStringArray c8;
- c8.push_back("strKaraLyrics");
- tables.insert(pair<CStdString, CStdStringArray> ("karaokedata", c8));
-
- CStdStringArray c9;
- c9.push_back("strTitle");
- c9.push_back("strFilename");
- c9.push_back("comment");
- tables.insert(pair<CStdString, CStdStringArray> ("song", c9));
-
- CStdStringArray c10;
- c10.push_back("strPath");
- tables.insert(pair<CStdString, CStdStringArray> ("path", c10));
-
- for (itt = tables.begin(); itt != tables.end(); ++itt)
+ CStdString q;
+ q = PrepareSQL("UPDATE `%s` SET", itt->first.c_str());
+ for (itc = itt->second.begin(); itc != itt->second.end(); ++itc)
{
- CStdString q;
- q = PrepareSQL("UPDATE `%s` SET", itt->first.c_str());
- for (itc = itt->second.begin(); itc != itt->second.end(); ++itc)
+ q += PrepareSQL(" `%s` = CONVERT(CAST(CONVERT(`%s` USING %s) AS BINARY) USING utf8)",
+ itc->c_str(), itc->c_str(), charset.c_str());
+ if (*itc != itt->second.back())
{
- q += PrepareSQL(" `%s` = CONVERT(CAST(CONVERT(`%s` USING %s) AS BINARY) USING utf8)",
- itc->c_str(), itc->c_str(), charset.c_str());
- if (*itc != itt->second.back())
- {
- q += ", ";
- }
+ q += ", ";
}
- m_pDS->exec(q);
}
+ m_pDS->exec(q);
}
}
- if (version < 17)
+ }
+ if (version < 17)
+ {
+ m_pDS->exec("CREATE INDEX idxAlbum2 ON album(idArtist)");
+ m_pDS->exec("CREATE INDEX idxSong3 ON song(idAlbum)");
+ m_pDS->exec("CREATE INDEX idxSong4 ON song(idArtist)");
+ m_pDS->exec("CREATE INDEX idxSong5 ON song(idGenre)");
+ m_pDS->exec("CREATE INDEX idxSong6 ON song(idPath)");
+ }
+ if (version < 19)
+ {
+ int len = g_advancedSettings.m_musicItemSeparator.size() + 1;
+ CStdString sql = PrepareSQL("UPDATE song SET strExtraArtists=SUBSTR(strExtraArtists,%i), strExtraGenres=SUBSTR(strExtraGenres,%i)", len, len);
+ m_pDS->exec(sql.c_str());
+ sql = PrepareSQL("UPDATE album SET strExtraArtists=SUBSTR(strExtraArtists,%i), strExtraGenres=SUBSTR(strExtraGenres,%i)", len, len);
+ m_pDS->exec(sql.c_str());
+ }
+
+ if (version < 21)
+ {
+ m_pDS->exec("CREATE TABLE album_artist ( idArtist integer, idAlbum integer, boolFeatured integer, iOrder integer )\n");
+ m_pDS->exec("CREATE UNIQUE INDEX idxAlbumArtist_1 ON album_artist ( idAlbum, idArtist )\n");
+ m_pDS->exec("CREATE UNIQUE INDEX idxAlbumArtist_2 ON album_artist ( idArtist, idAlbum )\n");
+ m_pDS->exec("CREATE INDEX idxAlbumArtist_3 ON album_artist ( boolFeatured )\n");
+ m_pDS->exec("INSERT INTO album_artist (idArtist, idAlbum, boolFeatured, iOrder) SELECT idArtist, idAlbum, 1, iPosition FROM exartistalbum");
+ m_pDS->exec("REPLACE INTO album_artist (idArtist, idAlbum, boolFeatured, iOrder) SELECT idArtist, idAlbum, 0, 0 FROM album");
+
+ CStdString strSQL;
+ strSQL=PrepareSQL("SELECT album.idAlbum AS idAlbum, strExtraArtists,"
+ " album.idArtist AS idArtist, strArtist FROM album "
+ " LEFT OUTER JOIN artist ON album.idArtist=artist.idArtist");
+ if (!m_pDS->query(strSQL.c_str()))
{
- m_pDS->exec("CREATE INDEX idxAlbum2 ON album(idArtist)");
- m_pDS->exec("CREATE INDEX idxSong3 ON song(idAlbum)");
- m_pDS->exec("CREATE INDEX idxSong4 ON song(idArtist)");
- m_pDS->exec("CREATE INDEX idxSong5 ON song(idGenre)");
- m_pDS->exec("CREATE INDEX idxSong6 ON song(idPath)");
+ CLog::Log(LOGDEBUG, "%s could not upgrade albums table", __FUNCTION__);
+ return false;
}
- if (version < 19)
+
+ VECALBUMS albums;
+ while (!m_pDS->eof())
{
- int len = g_advancedSettings.m_musicItemSeparator.size() + 1;
- CStdString sql = PrepareSQL("UPDATE song SET strExtraArtists=SUBSTR(strExtraArtists,%i), strExtraGenres=SUBSTR(strExtraGenres,%i)", len, len);
- m_pDS->exec(sql.c_str());
- sql = PrepareSQL("UPDATE album SET strExtraArtists=SUBSTR(strExtraArtists,%i), strExtraGenres=SUBSTR(strExtraGenres,%i)", len, len);
- m_pDS->exec(sql.c_str());
+ CAlbum album;
+ album.idAlbum = m_pDS->fv("idAlbum").get_asInt();
+ album.artist.push_back(m_pDS->fv("strArtist").get_asString());
+ if (!m_pDS->fv("strExtraArtists").get_asString().empty())
+ {
+ std::vector<std::string> extraArtists = StringUtils::Split(m_pDS->fv("strExtraArtists").get_asString(), g_advancedSettings.m_musicItemSeparator);
+ album.artist.insert(album.artist.end(), extraArtists.begin(), extraArtists.end());
+ }
+ albums.push_back(album);
+ m_pDS->next();
}
+ m_pDS->close();
+ m_pDS->exec("CREATE TABLE album_new ( idAlbum integer primary key, strAlbum varchar(256), strArtists text, idGenre integer, strExtraGenres text, iYear integer, idThumb integer)");
+ m_pDS->exec("INSERT INTO album_new ( idAlbum, strAlbum, idGenre, strExtraGenres, iYear, idThumb ) SELECT idAlbum, strAlbum, idGenre, strExtraGenres, iYear, idThumb FROM album");
- if (version < 21)
+ for (VECALBUMS::iterator it = albums.begin(); it != albums.end(); ++it)
{
- m_pDS->exec("CREATE TABLE album_artist ( idArtist integer, idAlbum integer, boolFeatured integer, iOrder integer )\n");
- m_pDS->exec("CREATE UNIQUE INDEX idxAlbumArtist_1 ON album_artist ( idAlbum, idArtist )\n");
- m_pDS->exec("CREATE UNIQUE INDEX idxAlbumArtist_2 ON album_artist ( idArtist, idAlbum )\n");
- m_pDS->exec("CREATE INDEX idxAlbumArtist_3 ON album_artist ( boolFeatured )\n");
- m_pDS->exec("INSERT INTO album_artist (idArtist, idAlbum, boolFeatured, iOrder) SELECT idArtist, idAlbum, 1, iPosition FROM exartistalbum");
- m_pDS->exec("REPLACE INTO album_artist (idArtist, idAlbum, boolFeatured, iOrder) SELECT idArtist, idAlbum, 0, 0 FROM album");
-
CStdString strSQL;
- strSQL=PrepareSQL("SELECT album.idAlbum AS idAlbum, strExtraArtists,"
- " album.idArtist AS idArtist, strArtist FROM album "
- " LEFT OUTER JOIN artist ON album.idArtist=artist.idArtist");
- if (!m_pDS->query(strSQL.c_str()))
- {
- CLog::Log(LOGDEBUG, "%s could not upgrade albums table", __FUNCTION__);
- return false;
- }
+ strSQL = PrepareSQL("UPDATE album_new SET strArtists='%s' WHERE idAlbum=%i", StringUtils::Join(it->artist, g_advancedSettings.m_musicItemSeparator).c_str(), it->idAlbum);
+ m_pDS->exec(strSQL);
+ }
- VECALBUMS albums;
- while (!m_pDS->eof())
- {
- CAlbum album;
- album.idAlbum = m_pDS->fv("idAlbum").get_asInt();
- album.artist.push_back(m_pDS->fv("strArtist").get_asString());
- if (!m_pDS->fv("strExtraArtists").get_asString().empty())
- {
- std::vector<std::string> extraArtists = StringUtils::Split(m_pDS->fv("strExtraArtists").get_asString(), g_advancedSettings.m_musicItemSeparator);
- album.artist.insert(album.artist.end(), extraArtists.begin(), extraArtists.end());
- }
- albums.push_back(album);
- m_pDS->next();
- }
- m_pDS->close();
- m_pDS->exec("CREATE TABLE album_new ( idAlbum integer primary key, strAlbum varchar(256), strArtists text, idGenre integer, strExtraGenres text, iYear integer, idThumb integer)");
- m_pDS->exec("INSERT INTO album_new ( idAlbum, strAlbum, idGenre, strExtraGenres, iYear, idThumb ) SELECT idAlbum, strAlbum, idGenre, strExtraGenres, iYear, idThumb FROM album");
+ m_pDS->exec("DROP TABLE album");
+ m_pDS->exec("ALTER TABLE album_new RENAME TO album");
+ m_pDS->exec("CREATE INDEX idxAlbum ON album(strAlbum)");
+ m_pDS->exec("DROP TABLE IF EXISTS exartistalbum");
+ }
- for (VECALBUMS::iterator it = albums.begin(); it != albums.end(); ++it)
- {
- CStdString strSQL;
- strSQL = PrepareSQL("UPDATE album_new SET strArtists='%s' WHERE idAlbum=%i", StringUtils::Join(it->artist, g_advancedSettings.m_musicItemSeparator).c_str(), it->idAlbum);
- m_pDS->exec(strSQL);
- }
+ if (version < 22)
+ {
+ m_pDS->exec("CREATE TABLE song_artist ( idArtist integer, idSong integer, boolFeatured integer, iOrder integer )\n");
+ m_pDS->exec("CREATE UNIQUE INDEX idxSongArtist_1 ON song_artist ( idSong, idArtist )\n");
+ m_pDS->exec("CREATE UNIQUE INDEX idxSongArtist_2 ON song_artist ( idArtist, idSong )\n");
+ m_pDS->exec("CREATE INDEX idxSongArtist_3 ON song_artist ( boolFeatured )\n");
+ m_pDS->exec("INSERT INTO song_artist (idArtist, idSong, boolFeatured, iOrder) SELECT idArtist, idSong, 1, iPosition FROM exartistsong");
+ m_pDS->exec("REPLACE INTO song_artist (idArtist, idSong, boolFeatured, iOrder) SELECT idArtist, idSong, 0, 0 FROM song");
- m_pDS->exec("DROP TABLE album");
- m_pDS->exec("ALTER TABLE album_new RENAME TO album");
- m_pDS->exec("CREATE INDEX idxAlbum ON album(strAlbum)");
- m_pDS->exec("DROP TABLE IF EXISTS exartistalbum");
+ CStdString strSQL;
+ strSQL=PrepareSQL("SELECT song.idSong AS idSong, strExtraArtists,"
+ " song.idArtist AS idArtist, strArtist FROM song "
+ " LEFT OUTER JOIN artist ON song.idArtist=artist.idArtist");
+ if (!m_pDS->query(strSQL.c_str()))
+ {
+ CLog::Log(LOGDEBUG, "%s could not upgrade songs table", __FUNCTION__);
+ return false;
}
- if (version < 22)
+ VECSONGS songs;
+ while (!m_pDS->eof())
{
- m_pDS->exec("CREATE TABLE song_artist ( idArtist integer, idSong integer, boolFeatured integer, iOrder integer )\n");
- m_pDS->exec("CREATE UNIQUE INDEX idxSongArtist_1 ON song_artist ( idSong, idArtist )\n");
- m_pDS->exec("CREATE UNIQUE INDEX idxSongArtist_2 ON song_artist ( idArtist, idSong )\n");
- m_pDS->exec("CREATE INDEX idxSongArtist_3 ON song_artist ( boolFeatured )\n");
- m_pDS->exec("INSERT INTO song_artist (idArtist, idSong, boolFeatured, iOrder) SELECT idArtist, idSong, 1, iPosition FROM exartistsong");
- m_pDS->exec("REPLACE INTO song_artist (idArtist, idSong, boolFeatured, iOrder) SELECT idArtist, idSong, 0, 0 FROM song");
-
- CStdString strSQL;
- strSQL=PrepareSQL("SELECT song.idSong AS idSong, strExtraArtists,"
- " song.idArtist AS idArtist, strArtist FROM song "
- " LEFT OUTER JOIN artist ON song.idArtist=artist.idArtist");
- if (!m_pDS->query(strSQL.c_str()))
- {
- CLog::Log(LOGDEBUG, "%s could not upgrade songs table", __FUNCTION__);
- return false;
- }
-
- VECSONGS songs;
- while (!m_pDS->eof())
- {
- CSong song;
- song.idSong = m_pDS->fv("idSong").get_asInt();
- song.artist.push_back(m_pDS->fv("strArtist").get_asString());
- if (!m_pDS->fv("strExtraArtists").get_asString().empty())
- {
- std::vector<std::string> extraArtists = StringUtils::Split(m_pDS->fv("strExtraArtists").get_asString(), g_advancedSettings.m_musicItemSeparator);
- song.artist.insert(song.artist.end(), extraArtists.begin(), extraArtists.end());
- }
- songs.push_back(song);
- m_pDS->next();
- }
- m_pDS->close();
- m_pDS->exec("CREATE TABLE song_new ( idSong integer primary key, idAlbum integer, idPath integer, strArtists text, idGenre integer, strExtraGenres text, strTitle varchar(512), iTrack integer, iDuration integer, iYear integer, dwFileNameCRC text, strFileName text, strMusicBrainzTrackID text, strMusicBrainzArtistID text, strMusicBrainzAlbumID text, strMusicBrainzAlbumArtistID text, strMusicBrainzTRMID text, iTimesPlayed integer, iStartOffset integer, iEndOffset integer, idThumb integer, lastplayed varchar(20) default NULL, rating char default '0', comment text)");
- m_pDS->exec("INSERT INTO song_new ( idSong, idAlbum, idPath, idGenre, strExtraGenres, strTitle, iTrack, iDuration, iYear, dwFileNameCRC, strFileName, strMusicBrainzTrackID, strMusicBrainzArtistID, strMusicBrainzAlbumID, strMusicBrainzAlbumArtistID, strMusicBrainzTRMID, iTimesPlayed, iStartOffset, iEndOffset, idThumb, lastplayed, rating, comment ) SELECT idSong, idAlbum, idPath, idGenre, strExtraGenres, strTitle, iTrack, iDuration, iYear, dwFileNameCRC, strFileName, strMusicBrainzTrackID, strMusicBrainzArtistID, strMusicBrainzAlbumID, strMusicBrainzAlbumArtistID, strMusicBrainzTRMID, iTimesPlayed, iStartOffset, iEndOffset, idThumb, lastplayed, rating, comment FROM song");
-
- for (VECSONGS::iterator it = songs.begin(); it != songs.end(); ++it)
+ CSong song;
+ song.idSong = m_pDS->fv("idSong").get_asInt();
+ song.artist.push_back(m_pDS->fv("strArtist").get_asString());
+ if (!m_pDS->fv("strExtraArtists").get_asString().empty())
{
- CStdString strSQL;
- strSQL = PrepareSQL("UPDATE song_new SET strArtists='%s' WHERE idSong=%i", StringUtils::Join(it->artist, g_advancedSettings.m_musicItemSeparator).c_str(), it->idSong);
- m_pDS->exec(strSQL);
+ std::vector<std::string> extraArtists = StringUtils::Split(m_pDS->fv("strExtraArtists").get_asString(), g_advancedSettings.m_musicItemSeparator);
+ song.artist.insert(song.artist.end(), extraArtists.begin(), extraArtists.end());
}
-
- m_pDS->exec("DROP TABLE song");
- m_pDS->exec("ALTER TABLE song_new RENAME TO song");
- m_pDS->exec("CREATE INDEX idxSong ON song(strTitle)");
- m_pDS->exec("CREATE INDEX idxSong1 ON song(iTimesPlayed)");
- m_pDS->exec("CREATE INDEX idxSong2 ON song(lastplayed)");
- m_pDS->exec("CREATE INDEX idxSong3 ON song(idAlbum)");
- m_pDS->exec("CREATE INDEX idxSong6 ON song(idPath)");
- m_pDS->exec("DROP TABLE IF EXISTS exartistsong");
+ songs.push_back(song);
+ m_pDS->next();
}
+ m_pDS->close();
+ m_pDS->exec("CREATE TABLE song_new ( idSong integer primary key, idAlbum integer, idPath integer, strArtists text, idGenre integer, strExtraGenres text, strTitle varchar(512), iTrack integer, iDuration integer, iYear integer, dwFileNameCRC text, strFileName text, strMusicBrainzTrackID text, strMusicBrainzArtistID text, strMusicBrainzAlbumID text, strMusicBrainzAlbumArtistID text, strMusicBrainzTRMID text, iTimesPlayed integer, iStartOffset integer, iEndOffset integer, idThumb integer, lastplayed varchar(20) default NULL, rating char default '0', comment text)");
+ m_pDS->exec("INSERT INTO song_new ( idSong, idAlbum, idPath, idGenre, strExtraGenres, strTitle, iTrack, iDuration, iYear, dwFileNameCRC, strFileName, strMusicBrainzTrackID, strMusicBrainzArtistID, strMusicBrainzAlbumID, strMusicBrainzAlbumArtistID, strMusicBrainzTRMID, iTimesPlayed, iStartOffset, iEndOffset, idThumb, lastplayed, rating, comment ) SELECT idSong, idAlbum, idPath, idGenre, strExtraGenres, strTitle, iTrack, iDuration, iYear, dwFileNameCRC, strFileName, strMusicBrainzTrackID, strMusicBrainzArtistID, strMusicBrainzAlbumID, strMusicBrainzAlbumArtistID, strMusicBrainzTRMID, iTimesPlayed, iStartOffset, iEndOffset, idThumb, lastplayed, rating, comment FROM song");
- if (version < 23)
+ for (VECSONGS::iterator it = songs.begin(); it != songs.end(); ++it)
{
- m_pDS->exec("CREATE TABLE album_genre ( idGenre integer, idAlbum integer, iOrder integer )\n");
- m_pDS->exec("CREATE UNIQUE INDEX idxAlbumGenre_1 ON album_genre ( idAlbum, idGenre )\n");
- m_pDS->exec("CREATE UNIQUE INDEX idxAlbumGenre_2 ON album_genre ( idGenre, idAlbum )\n");
- m_pDS->exec("INSERT INTO album_genre ( idGenre, idAlbum, iOrder) SELECT idGenre, idAlbum, iPosition FROM exgenrealbum");
- m_pDS->exec("REPLACE INTO album_genre ( idGenre, idAlbum, iOrder) SELECT idGenre, idAlbum, 0 FROM album");
-
CStdString strSQL;
- strSQL=PrepareSQL("SELECT album.idAlbum AS idAlbum, strExtraGenres,"
- " album.idGenre AS idGenre, strGenre FROM album "
- " JOIN genre ON album.idGenre=genre.idGenre");
- if (!m_pDS->query(strSQL.c_str()))
- {
- CLog::Log(LOGDEBUG, "%s could not upgrade albums table", __FUNCTION__);
- return false;
- }
+ strSQL = PrepareSQL("UPDATE song_new SET strArtists='%s' WHERE idSong=%i", StringUtils::Join(it->artist, g_advancedSettings.m_musicItemSeparator).c_str(), it->idSong);
+ m_pDS->exec(strSQL);
+ }
- VECALBUMS albums;
- while (!m_pDS->eof())
- {
- CAlbum album;
- album.idAlbum = m_pDS->fv("idAlbum").get_asInt();
- album.genre.push_back(m_pDS->fv("strGenre").get_asString());
- if (!m_pDS->fv("strExtraGenres").get_asString().empty())
- {
- std::vector<std::string> extraGenres = StringUtils::Split(m_pDS->fv("strExtraGenres").get_asString(), g_advancedSettings.m_musicItemSeparator);
- album.genre.insert(album.genre.end(), extraGenres.begin(), extraGenres.end());
- }
- albums.push_back(album);
- m_pDS->next();
- }
- m_pDS->close();
- m_pDS->exec("CREATE TABLE album_new ( idAlbum integer primary key, strAlbum varchar(256), strArtists text, strGenres text, iYear integer, idThumb integer)");
- m_pDS->exec("INSERT INTO album_new ( idAlbum, strAlbum, strArtists, iYear, idThumb) SELECT idAlbum, strAlbum, strArtists, iYear, idThumb FROM album");
+ m_pDS->exec("DROP TABLE song");
+ m_pDS->exec("ALTER TABLE song_new RENAME TO song");
+ m_pDS->exec("CREATE INDEX idxSong ON song(strTitle)");
+ m_pDS->exec("CREATE INDEX idxSong1 ON song(iTimesPlayed)");
+ m_pDS->exec("CREATE INDEX idxSong2 ON song(lastplayed)");
+ m_pDS->exec("CREATE INDEX idxSong3 ON song(idAlbum)");
+ m_pDS->exec("CREATE INDEX idxSong6 ON song(idPath)");
+ m_pDS->exec("DROP TABLE IF EXISTS exartistsong");
+ }
- for (VECALBUMS::iterator it = albums.begin(); it != albums.end(); ++it)
- {
- CStdString strSQL;
- strSQL = PrepareSQL("UPDATE album_new SET strGenres='%s' WHERE idAlbum=%i", StringUtils::Join(it->genre, g_advancedSettings.m_musicItemSeparator).c_str(), it->idAlbum);
- m_pDS->exec(strSQL);
- }
+ if (version < 23)
+ {
+ m_pDS->exec("CREATE TABLE album_genre ( idGenre integer, idAlbum integer, iOrder integer )\n");
+ m_pDS->exec("CREATE UNIQUE INDEX idxAlbumGenre_1 ON album_genre ( idAlbum, idGenre )\n");
+ m_pDS->exec("CREATE UNIQUE INDEX idxAlbumGenre_2 ON album_genre ( idGenre, idAlbum )\n");
+ m_pDS->exec("INSERT INTO album_genre ( idGenre, idAlbum, iOrder) SELECT idGenre, idAlbum, iPosition FROM exgenrealbum");
+ m_pDS->exec("REPLACE INTO album_genre ( idGenre, idAlbum, iOrder) SELECT idGenre, idAlbum, 0 FROM album");
- m_pDS->exec("DROP TABLE album");
- m_pDS->exec("ALTER TABLE album_new RENAME TO album");
- m_pDS->exec("CREATE INDEX idxAlbum ON album(strAlbum)");
- m_pDS->exec("DROP TABLE IF EXISTS exgenrealbum");
+ CStdString strSQL;
+ strSQL=PrepareSQL("SELECT album.idAlbum AS idAlbum, strExtraGenres,"
+ " album.idGenre AS idGenre, strGenre FROM album "
+ " JOIN genre ON album.idGenre=genre.idGenre");
+ if (!m_pDS->query(strSQL.c_str()))
+ {
+ CLog::Log(LOGDEBUG, "%s could not upgrade albums table", __FUNCTION__);
+ return false;
}
- if (version < 24)
+ VECALBUMS albums;
+ while (!m_pDS->eof())
{
- m_pDS->exec("CREATE TABLE song_genre ( idGenre integer, idSong integer, iOrder integer )\n");
- m_pDS->exec("CREATE UNIQUE INDEX idxSongGenre_1 ON song_genre ( idSong, idGenre )\n");
- m_pDS->exec("CREATE UNIQUE INDEX idxSongGenre_2 ON song_genre ( idGenre, idSong )\n");
- m_pDS->exec("INSERT INTO song_genre ( idGenre, idSong, iOrder) SELECT idGenre, idSong, iPosition FROM exgenresong");
- m_pDS->exec("REPLACE INTO song_genre ( idGenre, idSong, iOrder) SELECT idGenre, idSong, 0 FROM song");
-
- CStdString strSQL;
- strSQL=PrepareSQL("SELECT song.idSong AS idSong, strExtraGenres,"
- " song.idGenre AS idGenre, strGenre FROM song "
- " JOIN genre ON song.idGenre=genre.idGenre");
- if (!m_pDS->query(strSQL.c_str()))
+ CAlbum album;
+ album.idAlbum = m_pDS->fv("idAlbum").get_asInt();
+ album.genre.push_back(m_pDS->fv("strGenre").get_asString());
+ if (!m_pDS->fv("strExtraGenres").get_asString().empty())
{
- CLog::Log(LOGDEBUG, "%s could not upgrade songs table", __FUNCTION__);
- return false;
+ std::vector<std::string> extraGenres = StringUtils::Split(m_pDS->fv("strExtraGenres").get_asString(), g_advancedSettings.m_musicItemSeparator);
+ album.genre.insert(album.genre.end(), extraGenres.begin(), extraGenres.end());
}
+ albums.push_back(album);
+ m_pDS->next();
+ }
+ m_pDS->close();
+ m_pDS->exec("CREATE TABLE album_new ( idAlbum integer primary key, strAlbum varchar(256), strArtists text, strGenres text, iYear integer, idThumb integer)");
+ m_pDS->exec("INSERT INTO album_new ( idAlbum, strAlbum, strArtists, iYear, idThumb) SELECT idAlbum, strAlbum, strArtists, iYear, idThumb FROM album");
- VECSONGS songs;
- while (!m_pDS->eof())
- {
- CSong song;
- song.idSong = m_pDS->fv("idSong").get_asInt();
- song.genre.push_back(m_pDS->fv("strGenre").get_asString());
- if (!m_pDS->fv("strExtraGenres").get_asString().empty())
- {
- std::vector<std::string> extraGenres = StringUtils::Split(m_pDS->fv("strExtraGenres").get_asString(), g_advancedSettings.m_musicItemSeparator);
- song.genre.insert(song.genre.end(), extraGenres.begin(), extraGenres.end());
- }
- songs.push_back(song);
- m_pDS->next();
- }
- m_pDS->close();
- m_pDS->exec("CREATE TABLE song_new ( idSong integer primary key, idAlbum integer, idPath integer, strArtists text, strGenres text, strTitle varchar(512), iTrack integer, iDuration integer, iYear integer, dwFileNameCRC text, strFileName text, strMusicBrainzTrackID text, strMusicBrainzArtistID text, strMusicBrainzAlbumID text, strMusicBrainzAlbumArtistID text, strMusicBrainzTRMID text, iTimesPlayed integer, iStartOffset integer, iEndOffset integer, idThumb integer, lastplayed varchar(20) default NULL, rating char default '0', comment text)\n");
- m_pDS->exec("INSERT INTO song_new ( idSong, idAlbum, idPath, strArtists, strTitle, iTrack, iDuration, iYear, dwFileNameCRC, strFileName, strMusicBrainzTrackID, strMusicBrainzArtistID, strMusicBrainzAlbumID, strMusicBrainzAlbumArtistID, strMusicBrainzTRMID, iTimesPlayed, iStartOffset, iEndOffset, idThumb, lastplayed, rating, comment) SELECT idSong, idAlbum, idPath, strArtists, strTitle, iTrack, iDuration, iYear, dwFileNameCRC, strFileName, strMusicBrainzTrackID, strMusicBrainzArtistID, strMusicBrainzAlbumID, strMusicBrainzAlbumArtistID, strMusicBrainzTRMID, iTimesPlayed, iStartOffset, iEndOffset, idThumb, lastplayed, rating, comment FROM song");
+ for (VECALBUMS::iterator it = albums.begin(); it != albums.end(); ++it)
+ {
+ CStdString strSQL;
+ strSQL = PrepareSQL("UPDATE album_new SET strGenres='%s' WHERE idAlbum=%i", StringUtils::Join(it->genre, g_advancedSettings.m_musicItemSeparator).c_str(), it->idAlbum);
+ m_pDS->exec(strSQL);
+ }
- for (VECSONGS::iterator it = songs.begin(); it != songs.end(); ++it)
- {
- CStdString strSQL;
- strSQL = PrepareSQL("UPDATE song_new SET strGenres='%s' WHERE idSong=%i", StringUtils::Join(it->genre, g_advancedSettings.m_musicItemSeparator).c_str(), it->idSong);
- m_pDS->exec(strSQL);
- }
+ m_pDS->exec("DROP TABLE album");
+ m_pDS->exec("ALTER TABLE album_new RENAME TO album");
+ m_pDS->exec("CREATE INDEX idxAlbum ON album(strAlbum)");
+ m_pDS->exec("DROP TABLE IF EXISTS exgenrealbum");
+ }
- m_pDS->exec("DROP TABLE song");
- m_pDS->exec("ALTER TABLE song_new RENAME TO song");
- m_pDS->exec("CREATE INDEX idxSong ON song(strTitle)");
- m_pDS->exec("CREATE INDEX idxSong1 ON song(iTimesPlayed)");
- m_pDS->exec("CREATE INDEX idxSong2 ON song(lastplayed)");
- m_pDS->exec("CREATE INDEX idxSong3 ON song(idAlbum)");
- m_pDS->exec("CREATE INDEX idxSong6 ON song(idPath)");
- m_pDS->exec("DROP TABLE IF EXISTS exgenresong");
- }
+ if (version < 24)
+ {
+ m_pDS->exec("CREATE TABLE song_genre ( idGenre integer, idSong integer, iOrder integer )\n");
+ m_pDS->exec("CREATE UNIQUE INDEX idxSongGenre_1 ON song_genre ( idSong, idGenre )\n");
+ m_pDS->exec("CREATE UNIQUE INDEX idxSongGenre_2 ON song_genre ( idGenre, idSong )\n");
+ m_pDS->exec("INSERT INTO song_genre ( idGenre, idSong, iOrder) SELECT idGenre, idSong, iPosition FROM exgenresong");
+ m_pDS->exec("REPLACE INTO song_genre ( idGenre, idSong, iOrder) SELECT idGenre, idSong, 0 FROM song");
- if (version < 25)
+ CStdString strSQL;
+ strSQL=PrepareSQL("SELECT song.idSong AS idSong, strExtraGenres,"
+ " song.idGenre AS idGenre, strGenre FROM song "
+ " JOIN genre ON song.idGenre=genre.idGenre");
+ if (!m_pDS->query(strSQL.c_str()))
{
- m_pDS->exec("ALTER TABLE album ADD bCompilation integer not null default '0'");
- m_pDS->exec("CREATE INDEX idxAlbum_1 ON album(bCompilation)");
+ CLog::Log(LOGDEBUG, "%s could not upgrade songs table", __FUNCTION__);
+ return false;
}
- if (version < 26)
- { // add art table
- m_pDS->exec("CREATE TABLE art(art_id INTEGER PRIMARY KEY, media_id INTEGER, media_type TEXT, type TEXT, url TEXT)");
- m_pDS->exec("CREATE INDEX ix_art ON art(media_id, media_type(20), type(20))");
- m_pDS->exec("CREATE TRIGGER delete_song AFTER DELETE ON song FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idSong AND media_type='song'; END");
- m_pDS->exec("CREATE TRIGGER delete_album AFTER DELETE ON album FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idAlbum AND media_type='album'; END");
- m_pDS->exec("CREATE TRIGGER delete_artist AFTER DELETE ON artist FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idArtist AND media_type='artist'; END");
+ VECSONGS songs;
+ while (!m_pDS->eof())
+ {
+ CSong song;
+ song.idSong = m_pDS->fv("idSong").get_asInt();
+ song.genre.push_back(m_pDS->fv("strGenre").get_asString());
+ if (!m_pDS->fv("strExtraGenres").get_asString().empty())
+ {
+ std::vector<std::string> extraGenres = StringUtils::Split(m_pDS->fv("strExtraGenres").get_asString(), g_advancedSettings.m_musicItemSeparator);
+ song.genre.insert(song.genre.end(), extraGenres.begin(), extraGenres.end());
+ }
+ songs.push_back(song);
+ m_pDS->next();
}
+ m_pDS->close();
+ m_pDS->exec("CREATE TABLE song_new ( idSong integer primary key, idAlbum integer, idPath integer, strArtists text, strGenres text, strTitle varchar(512), iTrack integer, iDuration integer, iYear integer, dwFileNameCRC text, strFileName text, strMusicBrainzTrackID text, strMusicBrainzArtistID text, strMusicBrainzAlbumID text, strMusicBrainzAlbumArtistID text, strMusicBrainzTRMID text, iTimesPlayed integer, iStartOffset integer, iEndOffset integer, idThumb integer, lastplayed varchar(20) default NULL, rating char default '0', comment text)\n");
+ m_pDS->exec("INSERT INTO song_new ( idSong, idAlbum, idPath, strArtists, strTitle, iTrack, iDuration, iYear, dwFileNameCRC, strFileName, strMusicBrainzTrackID, strMusicBrainzArtistID, strMusicBrainzAlbumID, strMusicBrainzAlbumArtistID, strMusicBrainzTRMID, iTimesPlayed, iStartOffset, iEndOffset, idThumb, lastplayed, rating, comment) SELECT idSong, idAlbum, idPath, strArtists, strTitle, iTrack, iDuration, iYear, dwFileNameCRC, strFileName, strMusicBrainzTrackID, strMusicBrainzArtistID, strMusicBrainzAlbumID, strMusicBrainzAlbumArtistID, strMusicBrainzTRMID, iTimesPlayed, iStartOffset, iEndOffset, idThumb, lastplayed, rating, comment FROM song");
- if (version < 27)
+ for (VECSONGS::iterator it = songs.begin(); it != songs.end(); ++it)
{
- m_pDS->exec("DROP TABLE thumb");
-
- g_settings.m_musicNeedsUpdate = 27;
- g_settings.Save();
+ CStdString strSQL;
+ strSQL = PrepareSQL("UPDATE song_new SET strGenres='%s' WHERE idSong=%i", StringUtils::Join(it->genre, g_advancedSettings.m_musicItemSeparator).c_str(), it->idSong);
+ m_pDS->exec(strSQL);
}
- // always recreate the views after any table change
- CreateViews();
+ m_pDS->exec("DROP TABLE song");
+ m_pDS->exec("ALTER TABLE song_new RENAME TO song");
+ m_pDS->exec("CREATE INDEX idxSong ON song(strTitle)");
+ m_pDS->exec("CREATE INDEX idxSong1 ON song(iTimesPlayed)");
+ m_pDS->exec("CREATE INDEX idxSong2 ON song(lastplayed)");
+ m_pDS->exec("CREATE INDEX idxSong3 ON song(idAlbum)");
+ m_pDS->exec("CREATE INDEX idxSong6 ON song(idPath)");
+ m_pDS->exec("DROP TABLE IF EXISTS exgenresong");
+ }
+
+ if (version < 25)
+ {
+ m_pDS->exec("ALTER TABLE album ADD bCompilation integer not null default '0'");
+ m_pDS->exec("CREATE INDEX idxAlbum_1 ON album(bCompilation)");
+ }
+
+ if (version < 26)
+ { // add art table
+ m_pDS->exec("CREATE TABLE art(art_id INTEGER PRIMARY KEY, media_id INTEGER, media_type TEXT, type TEXT, url TEXT)");
+ m_pDS->exec("CREATE INDEX ix_art ON art(media_id, media_type(20), type(20))");
+ m_pDS->exec("CREATE TRIGGER delete_song AFTER DELETE ON song FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idSong AND media_type='song'; END");
+ m_pDS->exec("CREATE TRIGGER delete_album AFTER DELETE ON album FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idAlbum AND media_type='album'; END");
+ m_pDS->exec("CREATE TRIGGER delete_artist AFTER DELETE ON artist FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idArtist AND media_type='artist'; END");
+ }
+
+ if (version < 27)
+ {
+ m_pDS->exec("DROP TABLE thumb");
+
+ g_settings.m_musicNeedsUpdate = 27;
+ g_settings.Save();
+ }
+
+ // always recreate the views after any table change
+ CreateViews();
return true;
}
View
392 xbmc/video/VideoDatabase.cpp
@@ -3686,222 +3686,222 @@ bool CVideoDatabase::ScraperInUse(const CStdString &scraperID) const
bool CVideoDatabase::UpdateOldVersion(int iVersion)
{
- if (iVersion < 43)
- {
- m_pDS->exec("ALTER TABLE settings ADD VerticalShift float");
- }
- if (iVersion < 44)
+ if (iVersion < 43)
+ {
+ m_pDS->exec("ALTER TABLE settings ADD VerticalShift float");
+ }
+ if (iVersion < 44)
+ {
+ // only if MySQL is used and default character set is not utf8
+ // string data needs to be converted to proper utf8
+ CStdString charset = m_pDS->getDatabase()->getDefaultCharset();
+ if (!m_sqlite && !charset.empty() && charset != "utf8")
{
- // only if MySQL is used and default character set is not utf8
- // string data needs to be converted to proper utf8
- CStdString charset = m_pDS->getDatabase()->getDefaultCharset();
- if (!m_sqlite && !charset.empty() && charset != "utf8")
+ map<CStdString, CStdStringArray> tables;
+ map<CStdString, CStdStringArray>::iterator itt;
+ CStdStringArray::iterator itc;
+
+ // columns that need to be converted
+ // content columns
+ CStdStringArray c_columns;
+ for (int i = 0; i < 22; i++)
{
- map<CStdString, CStdStringArray> tables;
- map<CStdString, CStdStringArray>::iterator itt;
- CStdStringArray::iterator itc;
-
- // columns that need to be converted
- // content columns
- CStdStringArray c_columns;
- for (int i = 0; i < 22; i++)
- {
- CStdString c;
- c.Format("c%02d", i);
- c_columns.push_back(c);
- }
+ CStdString c;
+ c.Format("c%02d", i);
+ c_columns.push_back(c);
+ }
- tables.insert(pair<CStdString, CStdStringArray> ("episode", c_columns));
- tables.insert(pair<CStdString, CStdStringArray> ("movie", c_columns));
- tables.insert(pair<CStdString, CStdStringArray> ("musicvideo", c_columns));
- tables.insert(pair<CStdString, CStdStringArray> ("tvshow", c_columns));
+ tables.insert(pair<CStdString, CStdStringArray> ("episode", c_columns));
+ tables.insert(pair<CStdString, CStdStringArray> ("movie", c_columns));
+ tables.insert(pair<CStdString, CStdStringArray> ("musicvideo", c_columns));
+ tables.insert(pair<CStdString, CStdStringArray> ("tvshow", c_columns));
- //common columns
- CStdStringArray c1;
- c1.push_back("strRole");
- tables.insert(pair<CStdString, CStdStringArray> ("actorlinkepisode", c1));
- tables.insert(pair<CStdString, CStdStringArray> ("actorlinkmovie", c1));
- tables.insert(pair<CStdString, CStdStringArray> ("actorlinktvshow", c1));
+ //common columns
+ CStdStringArray c1;
+ c1.push_back("strRole");
+ tables.insert(pair<CStdString, CStdStringArray> ("actorlinkepisode", c1));
+ tables.insert(pair<CStdString, CStdStringArray> ("actorlinkmovie", c1));
+ tables.insert(pair<CStdString, CStdStringArray> ("actorlinktvshow", c1));
- //remaining columns
- CStdStringArray c2;
- c2.push_back("strActor");
- tables.insert(pair<CStdString, CStdStringArray> ("actors", c2));
+ //remaining columns
+ CStdStringArray c2;
+ c2.push_back("strActor");
+ tables.insert(pair<CStdString, CStdStringArray> ("actors", c2));
- CStdStringArray c3;
- c3.push_back("strCountry");
- tables.insert(pair<CStdString, CStdStringArray> ("country", c3));
+ CStdStringArray c3;
+ c3.push_back("strCountry");
+ tables.insert(pair<CStdString, CStdStringArray> ("country", c3));
- CStdStringArray c4;
- c4.push_back("strFilename");
- tables.insert(pair<CStdString, CStdStringArray> ("files", c4));
+ CStdStringArray c4;
+ c4.push_back("strFilename");
+ tables.insert(pair<CStdString, CStdStringArray> ("files", c4));
- CStdStringArray c5;
- c5.push_back("strGenre");
- tables.insert(pair<CStdString, CStdStringArray> ("genre", c5));
+ CStdStringArray c5;
+ c5.push_back("strGenre");
+ tables.insert(pair<CStdString, CStdStringArray> ("genre", c5));
- CStdStringArray c6;
- c6.push_back("strSet");
- tables.insert(pair<CStdString, CStdStringArray> ("sets", c6));
+ CStdStringArray c6;
+ c6.push_back("strSet");
+ tables.insert(pair<CStdString, CStdStringArray> ("sets", c6));
- CStdStringArray c7;
- c7.push_back("strStudio");
- tables.insert(pair<CStdString, CStdStringArray> ("studio", c7));
+ CStdStringArray c7;
+ c7.push_back("strStudio");
+ tables.insert(pair<CStdString, CStdStringArray> ("studio", c7));
- CStdStringArray c8;
- c8.push_back("strPath");
- tables.insert(pair<CStdString, CStdStringArray> ("path", c8));
+ CStdStringArray c8;
+ c8.push_back("strPath");
+ tables.insert(pair<CStdString, CStdStringArray> ("path", c8));
- for (itt = tables.begin(); itt != tables.end(); ++itt)
+ for (itt = tables.begin(); itt != tables.end(); ++itt)
+ {
+ CStdString q;
+ q = PrepareSQL("UPDATE `%s` SET", itt->first.c_str());
+ for (itc = itt->second.begin(); itc != itt->second.end(); ++itc)
{
- CStdString q;
- q = PrepareSQL("UPDATE `%s` SET", itt->first.c_str());
- for (itc = itt->second.begin(); itc != itt->second.end(); ++itc)
+ q += PrepareSQL(" `%s` = CONVERT(CAST(CONVERT(`%s` USING %s) AS BINARY) USING utf8)",
+ itc->c_str(), itc->c_str(), charset.c_str());
+ if (*itc != itt->second.back())
{
- q += PrepareSQL(" `%s` = CONVERT(CAST(CONVERT(`%s` USING %s) AS BINARY) USING utf8)",
- itc->c_str(), itc->c_str(), charset.c_str());
- if (*itc != itt->second.back())
- {
- q += ",";
- }
+ q += ",";
}
- m_pDS->exec(q);
}
+ m_pDS->exec(q);
}
}
- if (iVersion < 45)
- {
- m_pDS->exec("ALTER TABLE movie ADD c22 text");
- m_pDS->exec("ALTER TABLE episode ADD c22 text");
- m_pDS->exec("ALTER TABLE musicvideo ADD c22 text");
- m_pDS->exec("ALTER TABLE tvshow ADD c22 text");
- // Now update our tables
- UpdateBasePath("movie", "idMovie", VIDEODB_ID_BASEPATH);
- UpdateBasePath("musicvideo", "idMVideo", VIDEODB_ID_MUSICVIDEO_BASEPATH);
- UpdateBasePath("episode", "idEpisode", VIDEODB_ID_EPISODE_BASEPATH);
- UpdateBasePath("tvshow", "idShow", VIDEODB_ID_TV_BASEPATH, true);
- }
- if (iVersion < 46)
- { // add indices for dir entry lookups
- m_pDS->exec("CREATE INDEX ixMovieBasePath ON movie ( c22(255) )");
- m_pDS->exec("CREATE INDEX ixMusicVideoBasePath ON musicvideo ( c13(255) )");
- m_pDS->exec("CREATE INDEX ixEpisodeBasePath ON episode ( c18(255) )");
- m_pDS->exec("CREATE INDEX ixTVShowBasePath ON tvshow ( c16(255) )");
- }
- if (iVersion < 50)
- {
- m_pDS->exec("ALTER TABLE settings ADD ScalingMethod integer");
- m_pDS->exec(PrepareSQL("UPDATE settings set ScalingMethod=%i", g_settings.m_defaultVideoSettings.m_ScalingMethod));
- }
- if (iVersion < 51)
- {
- // Add iOrder fields to actorlink* tables to be able to list
- // actors by importance
- m_pDS->exec("ALTER TABLE actorlinkmovie ADD iOrder integer");
- m_pDS->exec("ALTER TABLE actorlinktvshow ADD iOrder integer");
- m_pDS->exec("ALTER TABLE actorlinkepisode ADD iOrder integer");
- }
- if (iVersion < 52)
- { // Add basepath link to path table for faster content retrieval, and indicies
- m_pDS->exec("ALTER TABLE movie ADD c23 text");
- m_pDS->exec("ALTER TABLE episode ADD c23 text");
- m_pDS->exec("ALTER TABLE musicvideo ADD c23 text");
- m_pDS->exec("ALTER TABLE tvshow ADD c23 text");
- m_pDS->dropIndex("movie", "ixMovieBasePath");
- m_pDS->dropIndex("musicvideo", "ixMusicVideoBasePath");
- m_pDS->dropIndex("episode", "ixEpisodeBasePath");
- m_pDS->dropIndex("tvshow", "ixTVShowBasePath");
- m_pDS->exec("CREATE INDEX ixMovieBasePath ON movie ( c23(12) )");
- m_pDS->exec("CREATE INDEX ixMusicVideoBasePath ON musicvideo ( c14(12) )");
- m_pDS->exec("CREATE INDEX ixEpisodeBasePath ON episode ( c19(12) )");
- m_pDS->exec("CREATE INDEX ixTVShowBasePath ON tvshow ( c17(12) )");
- // now update the base path links
- UpdateBasePathID("movie", "idMovie", VIDEODB_ID_BASEPATH, VIDEODB_ID_PARENTPATHID);
- UpdateBasePathID("musicvideo", "idMVideo", VIDEODB_ID_MUSICVIDEO_BASEPATH, VIDEODB_ID_MUSICVIDEO_PARENTPATHID);
- UpdateBasePathID("episode", "idEpisode", VIDEODB_ID_EPISODE_BASEPATH, VIDEODB_ID_EPISODE_PARENTPATHID);
- UpdateBasePathID("tvshow", "idShow", VIDEODB_ID_TV_BASEPATH, VIDEODB_ID_TV_PARENTPATHID);
- }
- if (iVersion < 54)
- { // Change INDEX for bookmark table
- m_pDS->dropIndex("bookmark", "ix_bookmark");
- m_pDS->exec("CREATE INDEX ix_bookmark ON bookmark (idFile, type)");
- }
- if (iVersion < 55)
- {
- m_pDS->exec("ALTER TABLE settings ADD DeinterlaceMode integer");
- m_pDS->exec("UPDATE settings SET DeinterlaceMode = 2 WHERE Deinterlace NOT IN (0,1)"); // anything other than none: method auto => mode force
- m_pDS->exec("UPDATE settings SET DeinterlaceMode = 1 WHERE Deinterlace = 1"); // method auto => mode auto
- m_pDS->exec("UPDATE settings SET DeinterlaceMode = 0, Deinterlace = 1 WHERE Deinterlace = 0"); // method none => mode off, method auto
- }
-
- if (iVersion < 59)
- { // base paths for video_ts and bdmv files was wrong (and inconsistent depending on where and when they were scanned)
- CStdString where = PrepareSQL(" WHERE files.strFileName LIKE 'VIDEO_TS.IFO' or files.strFileName LIKE 'index.BDMV'");
- UpdateBasePath("movie", "idMovie", VIDEODB_ID_BASEPATH, false, where);
- UpdateBasePath("musicvideo", "idMVideo", VIDEODB_ID_MUSICVIDEO_BASEPATH, false, where);
- UpdateBasePath("episode", "idEpisode", VIDEODB_ID_EPISODE_BASEPATH, false, where);
- UpdateBasePathID("movie", "idMovie", VIDEODB_ID_BASEPATH, VIDEODB_ID_PARENTPATHID);
- UpdateBasePathID("musicvideo", "idMVideo", VIDEODB_ID_MUSICVIDEO_BASEPATH, VIDEODB_ID_MUSICVIDEO_PARENTPATHID);
- UpdateBasePathID("episode", "idEpisode", VIDEODB_ID_EPISODE_BASEPATH, VIDEODB_ID_EPISODE_PARENTPATHID);
- }
- if (iVersion < 61)
- {
- m_pDS->exec("ALTER TABLE path ADD dateAdded text");
- m_pDS->exec("ALTER TABLE files ADD dateAdded text");
- }
- if (iVersion < 62)
- { // add seasons table
- m_pDS->exec("CREATE TABLE seasons ( idSeason integer primary key, idShow integer, season integer)");
- m_pDS->exec("CREATE INDEX ix_seasons ON seasons (idShow, season)");
- // insert all seasons for each show
- m_pDS->query("SELECT idShow FROM tvshow");
- while (!m_pDS->eof())
- {
- CStdString sql = PrepareSQL("INSERT INTO seasons (idShow,season)"
- " SELECT DISTINCT"
- " idShow,c%02d"
- " FROM"
- " episodeview"
- " WHERE idShow=%i", VIDEODB_ID_EPISODE_SEASON, m_pDS->fv(0).get_asInt());
- m_pDS2->exec(sql.c_str());
- // and the "all seasons node"
- sql = PrepareSQL("INSERT INTO seasons (idShow,season) VALUES(%i,-1)", m_pDS->fv(0).get_asInt());
- m_pDS2->exec(sql.c_str());
- m_pDS->next();
- }
+ }
+ if (iVersion < 45)
+ {
+ m_pDS->exec("ALTER TABLE movie ADD c22 text");
+ m_pDS->exec("ALTER TABLE episode ADD c22 text");
+ m_pDS->exec("ALTER TABLE musicvideo ADD c22 text");
+ m_pDS->exec("ALTER TABLE tvshow ADD c22 text");
+ // Now update our tables
+ UpdateBasePath("movie", "idMovie", VIDEODB_ID_BASEPATH);
+ UpdateBasePath("musicvideo", "idMVideo", VIDEODB_ID_MUSICVIDEO_BASEPATH);
+ UpdateBasePath("episode", "idEpisode", VIDEODB_ID_EPISODE_BASEPATH);
+ UpdateBasePath("tvshow", "idShow", VIDEODB_ID_TV_BASEPATH, true);
+ }
+ if (iVersion < 46)
+ { // add indices for dir entry lookups
+ m_pDS->exec("CREATE INDEX ixMovieBasePath ON movie ( c22(255) )");
+ m_pDS->exec("CREATE INDEX ixMusicVideoBasePath ON musicvideo ( c13(255) )");
+ m_pDS->exec("CREATE INDEX ixEpisodeBasePath ON episode ( c18(255) )");
+ m_pDS->exec("CREATE INDEX ixTVShowBasePath ON tvshow ( c16(255) )");
+ }
+ if (iVersion < 50)
+ {
+ m_pDS->exec("ALTER TABLE settings ADD ScalingMethod integer");
+ m_pDS->exec(PrepareSQL("UPDATE settings set ScalingMethod=%i", g_settings.m_defaultVideoSettings.m_ScalingMethod));
+ }
+ if (iVersion < 51)
+ {
+ // Add iOrder fields to actorlink* tables to be able to list
+ // actors by importance
+ m_pDS->exec("ALTER TABLE actorlinkmovie ADD iOrder integer");
+ m_pDS->exec("ALTER TABLE actorlinktvshow ADD iOrder integer");
+ m_pDS->exec("ALTER TABLE actorlinkepisode ADD iOrder integer");
+ }
+ if (iVersion < 52)
+ { // Add basepath link to path table for faster content retrieval, and indicies
+ m_pDS->exec("ALTER TABLE movie ADD c23 text");
+ m_pDS->exec("ALTER TABLE episode ADD c23 text");
+ m_pDS->exec("ALTER TABLE musicvideo ADD c23 text");
+ m_pDS->exec("ALTER TABLE tvshow ADD c23 text");
+ m_pDS->dropIndex("movie", "ixMovieBasePath");
+ m_pDS->dropIndex("musicvideo", "ixMusicVideoBasePath");
+ m_pDS->dropIndex("episode", "ixEpisodeBasePath");
+ m_pDS->dropIndex("tvshow", "ixTVShowBasePath");
+ m_pDS->exec("CREATE INDEX ixMovieBasePath ON movie ( c23(12) )");
+ m_pDS->exec("CREATE INDEX ixMusicVideoBasePath ON musicvideo ( c14(12) )");
+ m_pDS->exec("CREATE INDEX ixEpisodeBasePath ON episode ( c19(12) )");
+ m_pDS->exec("CREATE INDEX ixTVShowBasePath ON tvshow ( c17(12) )");
+ // now update the base path links
+ UpdateBasePathID("movie", "idMovie", VIDEODB_ID_BASEPATH, VIDEODB_ID_PARENTPATHID);
+ UpdateBasePathID("musicvideo", "idMVideo", VIDEODB_ID_MUSICVIDEO_BASEPATH, VIDEODB_ID_MUSICVIDEO_PARENTPATHID);
+ UpdateBasePathID("episode", "idEpisode", VIDEODB_ID_EPISODE_BASEPATH, VIDEODB_ID_EPISODE_PARENTPATHID);
+ UpdateBasePathID("tvshow", "idShow", VIDEODB_ID_TV_BASEPATH, VIDEODB_ID_TV_PARENTPATHID);
+ }
+ if (iVersion < 54)
+ { // Change INDEX for bookmark table
+ m_pDS->dropIndex("bookmark", "ix_bookmark");
+ m_pDS->exec("CREATE INDEX ix_bookmark ON bookmark (idFile, type)");
+ }
+ if (iVersion < 55)
+ {
+ m_pDS->exec("ALTER TABLE settings ADD DeinterlaceMode integer");
+ m_pDS->exec("UPDATE settings SET DeinterlaceMode = 2 WHERE Deinterlace NOT IN (0,1)"); // anything other than none: method auto => mode force
+ m_pDS->exec("UPDATE settings SET DeinterlaceMode = 1 WHERE Deinterlace = 1"); // method auto => mode auto
+ m_pDS->exec("UPDATE settings SET DeinterlaceMode = 0, Deinterlace = 1 WHERE Deinterlace = 0"); // method none => mode off, method auto
+ }
+
+ if (iVersion < 59)
+ { // base paths for video_ts and bdmv files was wrong (and inconsistent depending on where and when they were scanned)
+ CStdString where = PrepareSQL(" WHERE files.strFileName LIKE 'VIDEO_TS.IFO' or files.strFileName LIKE 'index.BDMV'");
+ UpdateBasePath("movie", "idMovie", VIDEODB_ID_BASEPATH, false, where);
+ UpdateBasePath("musicvideo", "idMVideo", VIDEODB_ID_MUSICVIDEO_BASEPATH, false, where);
+ UpdateBasePath("episode", "idEpisode", VIDEODB_ID_EPISODE_BASEPATH, false, where);
+ UpdateBasePathID("movie", "idMovie", VIDEODB_ID_BASEPATH, VIDEODB_ID_PARENTPATHID);
+ UpdateBasePathID("musicvideo", "idMVideo", VIDEODB_ID_MUSICVIDEO_BASEPATH, VIDEODB_ID_MUSICVIDEO_PARENTPATHID);
+ UpdateBasePathID("episode", "idEpisode", VIDEODB_ID_EPISODE_BASEPATH, VIDEODB_ID_EPISODE_PARENTPATHID);
+ }
+ if (iVersion < 61)
+ {
+ m_pDS->exec("ALTER TABLE path ADD dateAdded text");
+ m_pDS->exec("ALTER TABLE files ADD dateAdded text");
+ }
+ if (iVersion < 62)
+ { // add seasons table
+ m_pDS->exec("CREATE TABLE seasons ( idSeason integer primary key, idShow integer, season integer)");
+ m_pDS->exec("CREATE INDEX ix_seasons ON seasons (idShow, season)");
+ // insert all seasons for each show
+ m_pDS->query("SELECT idShow FROM tvshow");
+ while (!m_pDS->eof())
+ {
+ CStdString sql = PrepareSQL("INSERT INTO seasons (idShow,season)"
+ " SELECT DISTINCT"
+ " idShow,c%02d"
+ " FROM"
+ " episodeview"
+ " WHERE idShow=%i", VIDEODB_ID_EPISODE_SEASON, m_pDS->fv(0).get_asInt());
+ m_pDS2->exec(sql.c_str());
+ // and the "all seasons node"
+ sql = PrepareSQL("INSERT INTO seasons (idShow,season) VALUES(%i,-1)", m_pDS->fv(0).get_asInt());
+ m_pDS2->exec(sql.c_str());
+ m_pDS->next();
}
- if (iVersion < 63)
- { // add art table
- m_pDS->exec("CREATE TABLE art(art_id INTEGER PRIMARY KEY, media_id INTEGER, media_type TEXT, type TEXT, url TEXT)");
- m_pDS->exec("CREATE INDEX ix_art ON art(media_id, media_type(20), type(20))");
- m_pDS->exec("CREATE TRIGGER delete_movie AFTER DELETE ON movie FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idMovie AND media_type='movie'; END");
- m_pDS->exec("CREATE TRIGGER delete_tvshow AFTER DELETE ON tvshow FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idShow AND media_type='tvshow'; END");
- m_pDS->exec("CREATE TRIGGER delete_musicvideo AFTER DELETE ON musicvideo FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idMVideo AND media_type='musicvideo'; END");
- m_pDS->exec("CREATE TRIGGER delete_episode AFTER DELETE ON episode FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idEpisode AND media_type='episode'; END");
- m_pDS->exec("CREATE TRIGGER delete_season AFTER DELETE ON seasons FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idSeason AND media_type='season'; END");
- m_pDS->exec("CREATE TRIGGER delete_set AFTER DELETE ON sets FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idSet AND media_type='set'; END");
- m_pDS->exec("CREATE TRIGGER delete_person AFTER DELETE ON actors FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idActor AND media_type IN ('actor','artist','writer','director'); END");
-
- g_settings.m_videoNeedsUpdate = 63;
- g_settings.Save();
- }
- if (iVersion < 64)
- { // add idShow to episode table
- m_pDS->exec("ALTER TABLE episode ADD idShow integer");
- m_pDS->query("SELECT idEpisode FROM episode");
- while (!m_pDS->eof())
- {
- int idEpisode = m_pDS->fv(0).get_asInt();
- CStdString update = PrepareSQL("UPDATE episode SET idShow=(SELECT idShow FROM tvshowlinkepisode WHERE idEpisode=%d) WHERE idEpisode=%d", idEpisode, idEpisode);
- m_pDS2->exec(update.c_str());
- m_pDS->next();
- }
- m_pDS->exec("DROP TABLE tvshowlinkepisode");
- m_pDS->exec("CREATE INDEX ix_episode_show1 on episode(idEpisode,idShow)");
- m_pDS->exec("CREATE INDEX ix_episode_show2 on episode(idShow,idEpisode)");
+ }
+ if (iVersion < 63)
+ { // add art table
+ m_pDS->exec("CREATE TABLE art(art_id INTEGER PRIMARY KEY, media_id INTEGER, media_type TEXT, type TEXT, url TEXT)");
+ m_pDS->exec("CREATE INDEX ix_art ON art(media_id, media_type(20), type(20))");
+ m_pDS->exec("CREATE TRIGGER delete_movie AFTER DELETE ON movie FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idMovie AND media_type='movie'; END");
+ m_pDS->exec("CREATE TRIGGER delete_tvshow AFTER DELETE ON tvshow FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idShow AND media_type='tvshow'; END");
+ m_pDS->exec("CREATE TRIGGER delete_musicvideo AFTER DELETE ON musicvideo FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idMVideo AND media_type='musicvideo'; END");
+ m_pDS->exec("CREATE TRIGGER delete_episode AFTER DELETE ON episode FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idEpisode AND media_type='episode'; END");
+ m_pDS->exec("CREATE TRIGGER delete_season AFTER DELETE ON seasons FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idSeason AND media_type='season'; END");
+ m_pDS->exec("CREATE TRIGGER delete_set AFTER DELETE ON sets FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idSet AND media_type='set'; END");
+ m_pDS->exec("CREATE TRIGGER delete_person AFTER DELETE ON actors FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idActor AND media_type IN ('actor','artist','writer','director'); END");
+
+ g_settings.m_videoNeedsUpdate = 63;
+ g_settings.Save();
+ }
+ if (iVersion < 64)
+ { // add idShow to episode table
+ m_pDS->exec("ALTER TABLE episode ADD idShow integer");
+ m_pDS->query("SELECT idEpisode FROM episode");
+ while (!m_pDS->eof())
+ {
+ int idEpisode = m_pDS->fv(0).get_asInt();
+ CStdString update = PrepareSQL("UPDATE episode SET idShow=(SELECT idShow FROM tvshowlinkepisode WHERE idEpisode=%d) WHERE idEpisode=%d", idEpisode, idEpisode);
+ m_pDS2->exec(update.c_str());
+ m_pDS->next();
}
- // always recreate the view after any table change
- CreateViews();
+ m_pDS->exec("DROP TABLE tvshowlinkepisode");
+ m_pDS->exec("CREATE INDEX ix_episode_show1 on episode(idEpisode,idShow)");
+ m_pDS->exec("CREATE INDEX ix_episode_show2 on episode(idShow,idEpisode)");
+ }
+ // always recreate the view after any table change
+ CreateViews();
return true;
}
Please sign in to comment.
Something went wrong with that request. Please try again.