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

Folder: Split triggers & indices creation in a specific method

parent 616c6ea1
......@@ -93,6 +93,13 @@ void Folder::createTable( sqlite::Connection* connection)
"(id_folder) ON DELETE CASCADE,"
"UNIQUE(folder_id) ON CONFLICT FAIL"
")";
sqlite::Tools::executeRequest( connection, req );
sqlite::Tools::executeRequest( connection, exclEntryReq );
}
void Folder::createTriggers( sqlite::Connection* connection )
{
std::string triggerReq = "CREATE TRIGGER IF NOT EXISTS is_device_present AFTER UPDATE OF is_present ON "
+ policy::DeviceTable::Name +
" WHEN old.is_present != new.is_present"
......@@ -103,8 +110,7 @@ void Folder::createTable( sqlite::Connection* connection)
policy::FolderTable::Name + " (device_id)";
std::string parentFolderIndexReq = "CREATE INDEX IF NOT EXISTS parent_folder_id_idx ON " +
policy::FolderTable::Name + " (parent_id)";
sqlite::Tools::executeRequest( connection, req );
sqlite::Tools::executeRequest( connection, exclEntryReq );
sqlite::Tools::executeRequest( connection, triggerReq );
sqlite::Tools::executeRequest( connection, deviceIndexReq );
sqlite::Tools::executeRequest( connection, parentFolderIndexReq );
......
......@@ -61,6 +61,7 @@ public:
Folder(MediaLibraryPtr ml, const std::string& path, int64_t parent , int64_t deviceId , bool isRemovable );
static void createTable( sqlite::Connection* connection );
static void createTriggers( sqlite::Connection* connection );
static std::shared_ptr<Folder> create( MediaLibraryPtr ml, const std::string& mrl, int64_t parentId, Device& device, fs::IDevice& deviceFs );
static void excludeEntryFolder( MediaLibraryPtr ml, int64_t folderId );
static bool blacklist( MediaLibraryPtr ml, const std::string& mrl );
......
......@@ -162,6 +162,7 @@ void MediaLibrary::createAllTables()
void MediaLibrary::createAllTriggers()
{
auto dbModelVersion = m_settings.dbModelVersion();
Folder::createTriggers( m_dbConnection.get() );
Album::createTriggers( m_dbConnection.get() );
AlbumTrack::createTriggers( m_dbConnection.get() );
Artist::createTriggers( m_dbConnection.get(), dbModelVersion );
......
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