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

migration: 25 -> 26: Fix missing file_type from restore tasks

Fix #244
parent e12a0c6e
Pipeline #17225 passed with stage
in 19 minutes and 1 second
......@@ -33,3 +33,19 @@ Show::trigger( Show::Triggers::DeleteFts, 26 ),
"DROP TRIGGER " + MediaGroup::triggerName( MediaGroup::Triggers::IncrementNbMediaOnGroupChange, 25 ),
"DROP TRIGGER " + MediaGroup::triggerName( MediaGroup::Triggers::DecrementNbMediaOnGroupChange, 25 ),
MediaGroup::trigger( MediaGroup::Triggers::UpdateNbMedia, 26 ),
/*
* Ensure we don't have restore tasks with no file_type specified. At this point
* the only restore tasks that can be found in database are playlist restoration
* tasks.
*/
"UPDATE " + parser::Task::Table::Name + " SET file_type = " +
std::to_string( static_cast<std::underlying_type_t<IFile::Type>>(
IFile::Type::Playlist ) ) +
" WHERE type = " +
std::to_string( static_cast<std::underlying_type_t<parser::Task::Type>>(
parser::Task::Type::Restore ) ) +
" AND file_type = " +
std::to_string( static_cast<std::underlying_type_t<IFile::Type>>(
IFile::Type::Unknown ) ),
......@@ -658,4 +658,18 @@ TEST_F( DbModel, Upgrade25to26 )
auto show = ml->createShow( "new test show" );
ASSERT_NE( nullptr, show );
/* Ensure we don't have any restore task with unknown file_type field anymode */
uint32_t nbUnknownFileTypeRestoreTask;
{
sqlite::Statement stmt{
ml->getConn()->handle(),
"SELECT COUNT(*) FROM " + parser::Task::Table::Name +
" WHERE file_type = ? AND type = ? "
};
stmt.execute( IFile::Type::Unknown, parser::Task::Type::Restore );
auto row = stmt.row();
row >> nbUnknownFileTypeRestoreTask;
}
ASSERT_EQ( 0u, nbUnknownFileTypeRestoreTask );
}
......@@ -161,4 +161,5 @@ INSERT INTO Task VALUES(1,3,0,0,'file:///home/chouquette/dev/medialibrary/test/s
INSERT INTO Task VALUES(2,3,0,0,'file:///home/chouquette/dev/medialibrary/test/samples/samples/music/compilation/track2.mp3',1,2,1,0,0,0,'');
INSERT INTO Task VALUES(3,3,0,0,'file:///home/chouquette/dev/medialibrary/test/samples/samples/music/compilation/track3.mp3',1,3,1,0,0,0,'');
INSERT INTO Task VALUES(4,3,0,0,'file:///home/chouquette/dev/medialibrary/test/samples/samples/music/compilation/track4.mp3',1,4,1,0,0,0,'');
INSERT INTO Task VALUES(5,0,0,3,'file:///home/chouquette/dev/medialibrary/path/to/backup/playlist1.xspf',0,NULL,NULL,0,0,0,'');
COMMIT;
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