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

migration: Handle metadata table

parent 9fbc3952
......@@ -58,6 +58,29 @@
"CASE thumbnail WHEN NULL THEN 0 WHEN '' THEN 0 ELSE 1 END,"
"title, filename, is_favorite, is_present FROM " + MediaTable::Name + "_backup",
/******************* Migrate metadata table ***********************************/
"CREATE TEMPORARY TABLE " + MetadataTable::Name + "_backup"
"("
"id_media INTEGER,"
"type INTEGER,"
"value TEXT"
")",
"INSERT INTO " + MetadataTable::Name + "_backup SELECT * FROM " + MetadataTable::Name,
"DROP TABLE " + MetadataTable::Name,
// Recreate the new table
#include "database/tables/Metadata_v14.sql"
"INSERT INTO " + MetadataTable::Name + " "
"SELECT "
"id_media, " + std::to_string(
static_cast<typename std::underlying_type<IMetadata::EntityType>::type>(
IMetadata::EntityType::Media ) ) +
", type, value "
"FROM " + MetadataTable::Name + "_backup",
/******************* Delete other tables **************************************/
"DROP TABLE " + AlbumTable::Name,
......
......@@ -32,6 +32,7 @@
#include "Artist.h"
#include "Media.h"
#include "Metadata.h"
class Misc : public Tests
{
......@@ -190,5 +191,10 @@ TEST_F( DbModel, Upgrade13to14 )
ASSERT_EQ( m->thumbnail(), "" );
ASSERT_FALSE( m->isThumbnailGenerated() );
// Ensure we're probing the correct fake media
ASSERT_EQ( m->id(), 2 );
auto& meta = m->metadata( IMedia::MetadataType::Progress );
ASSERT_EQ( "fake progress", meta.str() );
CheckNbTriggers( 32 );
}
......@@ -77,4 +77,5 @@ INSERT INTO `Media` (id_media,type,subtype,duration,play_count,last_played_date,
INSERT INTO `File` (id_file,media_id,playlist_id,mrl,type,last_modification_date,size,folder_id,is_present,is_removable,is_external) VALUES (1,1,NULL,'media.avi',1,NULL,NULL,NULL,1,0,1);
INSERT INTO `Media` (id_media,type,subtype,duration,play_count,last_played_date,insertion_date,release_date,thumbnail,title,filename,is_favorite,is_present) VALUES (2,3,NULL,-1,NULL,NULL,1522231538,NULL,'','media2.avi','media2.avi',0,1);
INSERT INTO `File` (id_file,media_id,playlist_id,mrl,type,last_modification_date,size,folder_id,is_present,is_removable,is_external) VALUES (2,2,NULL,'media2.avi',1,NULL,NULL,NULL,1,0,1);
INSERT INTO `MediaMetadata` VALUES(2, 50, "fake progress");
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