Commit 5d496969 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Genre: Remove on_track_genre_changed trigger

parent c65697dc
......@@ -143,13 +143,6 @@ void Genre::createTriggers( sqlite::Connection* dbConn )
" BEGIN"
" DELETE FROM " + Genre::Table::Name + "Fts WHERE rowid = old.id_genre;"
" END";
const std::string onGenreChanged = "CREATE TRIGGER IF NOT EXISTS on_track_genre_changed AFTER UPDATE OF "
" genre_id ON " + AlbumTrack::Table::Name +
" BEGIN"
" UPDATE " + Genre::Table::Name + " SET nb_tracks = nb_tracks + 1 WHERE id_genre = new.genre_id;"
" UPDATE " + Genre::Table::Name + " SET nb_tracks = nb_tracks - 1 WHERE id_genre = old.genre_id;"
" DELETE FROM " + Genre::Table::Name + " WHERE nb_tracks = 0;"
" END";
const std::string onTrackCreated = "CREATE TRIGGER IF NOT EXISTS update_genre_on_new_track"
" AFTER INSERT ON " + AlbumTrack::Table::Name +
" WHEN new.genre_id IS NOT NULL"
......@@ -166,7 +159,6 @@ void Genre::createTriggers( sqlite::Connection* dbConn )
sqlite::Tools::executeRequest( dbConn, vtableInsertTrigger );
sqlite::Tools::executeRequest( dbConn, vtableDeleteTrigger );
sqlite::Tools::executeRequest( dbConn, onGenreChanged );
sqlite::Tools::executeRequest( dbConn, onTrackCreated );
sqlite::Tools::executeRequest( dbConn, onTrackDeleted );
}
......
......@@ -136,6 +136,10 @@ IMedia::Type::Unknown ) ),
"DROP TABLE " + Device::Table::Name + "_backup",
/******************* Delete removed triggers **********************************/
"DROP TRIGGER on_track_genre_changed",
/******************* Delete other tables **************************************/
"DROP TABLE " + Album::Table::Name,
......
......@@ -174,7 +174,7 @@ TEST_F( DbModel, Upgrade12to13 )
// We can't check for the number of albums anymore since they are deleted
// as part of 13 -> 14 migration
CheckNbTriggers( 34 );
CheckNbTriggers( 33 );
}
TEST_F( DbModel, Upgrade13to14 )
......@@ -216,5 +216,5 @@ TEST_F( DbModel, Upgrade13to14 )
ASSERT_EQ( 0u, std::static_pointer_cast<Media>( externalMedia )->nbPlaylists() );
CheckNbTriggers( 34 );
CheckNbTriggers( 33 );
}
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