Commit 616c6ea1 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

AlbumTrack: Split triggers creation in a specific method

parent 43775746
......@@ -105,6 +105,12 @@ void AlbumTrack::createTable( sqlite::Connection* dbConnection )
"FOREIGN KEY (album_id) REFERENCES Album(id_album) "
" ON DELETE CASCADE"
")";
sqlite::Tools::executeRequest( dbConnection, req );
}
void AlbumTrack::createTriggers(sqlite::Connection* dbConnection)
{
const std::string triggerReq = "CREATE TRIGGER IF NOT EXISTS is_track_present"
"AFTER UPDATE OF is_present "
"ON " + policy::MediaTable::Name + " "
......@@ -116,8 +122,6 @@ void AlbumTrack::createTable( sqlite::Connection* dbConnection )
"album_media_artist_genre_album_idx ON " +
policy::AlbumTrackTable::Name +
"(media_id, artist_id, genre_id, album_id)";
sqlite::Tools::executeRequest( dbConnection, req );
sqlite::Tools::executeRequest( dbConnection, triggerReq );
sqlite::Tools::executeRequest( dbConnection, indexReq );
}
......
......@@ -68,6 +68,7 @@ class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy
virtual std::shared_ptr<IMedia> media() override;
static void createTable( sqlite::Connection* dbConnection );
static void createTriggers( sqlite::Connection* dbConnection );
static std::shared_ptr<AlbumTrack> create(MediaLibraryPtr ml, int64_t albumId,
std::shared_ptr<Media> media, unsigned int trackNb,
unsigned int discNumber, int64_t artistId, int64_t genreId,
......
......@@ -163,6 +163,7 @@ void MediaLibrary::createAllTriggers()
{
auto dbModelVersion = m_settings.dbModelVersion();
Album::createTriggers( m_dbConnection.get() );
AlbumTrack::createTriggers( m_dbConnection.get() );
Artist::createTriggers( m_dbConnection.get(), dbModelVersion );
Media::createTriggers( m_dbConnection.get() );
File::createTriggers( m_dbConnection.get() );
......
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