Commit 367dfaab authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Don't create virtual tables multiple times

parent 39fbdbf7
......@@ -279,7 +279,8 @@ bool Album::createTable(DBConnection dbConnection )
"FOREIGN KEY(artist_id) REFERENCES " + policy::ArtistTable::Name + "("
+ policy::ArtistTable::PrimaryKeyColumn + ") ON DELETE CASCADE"
")";
static const std::string vtableReq = "CREATE VIRTUAL TABLE " + policy::AlbumTable::Name + "Fts USING FTS3("
static const std::string vtableReq = "CREATE VIRTUAL TABLE IF NOT EXISTS "
+ policy::AlbumTable::Name + "Fts USING FTS3("
"title,"
"artist"
")";
......
......@@ -112,7 +112,8 @@ bool AlbumTrack::createTable( DBConnection dbConnection )
" BEGIN"
" UPDATE " + policy::AlbumTrackTable::Name + " SET is_present = new.is_present WHERE media_id = new.id_media;"
" END";
static const std::string vtableReq = "CREATE VIRTUAL TABLE " + policy::AlbumTrackTable::Name + "Fts USING FTS3("
static const std::string vtableReq = "CREATE VIRTUAL TABLE IF NOT EXISTS "
+ policy::AlbumTrackTable::Name + "Fts USING FTS3("
"title"
")";
static const std::string vtableTrigger = "CREATE TRIGGER IF NOT EXISTS delete_fts_track"
......
......@@ -128,7 +128,8 @@ bool Playlist::createTable( DBConnection dbConn )
"FOREIGN KEY(playlist_id) REFERENCES " + policy::PlaylistTable::Name + "("
+ policy::PlaylistTable::PrimaryKeyColumn + ") ON DELETE CASCADE"
")";
static const std::string vtableReq = "CREATE VIRTUAL TABLE " + policy::PlaylistTable::Name + "Fts USING FTS3("
static const std::string vtableReq = "CREATE VIRTUAL TABLE IF NOT EXISTS "
+ policy::PlaylistTable::Name + "Fts USING FTS3("
"name"
")";
//FIXME Enforce (playlist_id,position) uniqueness
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment