Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
30c7bf0c
Commit
30c7bf0c
authored
Mar 30, 2018
by
Hugo Beauzée-Luyssen
Browse files
MediaLibrary: Add missing bits to the model 12 to 13 migration
parent
9f87a32a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/MediaLibrary.cpp
View file @
30c7bf0c
...
...
@@ -1024,12 +1024,33 @@ void MediaLibrary::migrateModel10to11()
t
->
commit
();
}
/*
* - Some is_present related triggers were fixed in model 6 to 7 migration, but
* they were not recreated if already existing. The has_file_present trigger
* was recreated as part of model 7 to 8 migration, but we need to ensure
* has_album_present (Artist) & is_album_present (Album) triggers are
* recreated to behave as expected
* - Due to a typo, is_track_present was named is_track_presentAFTER, and was
* executed BEFORE the update took place, thus using the wrong is_present value.
* The trigger will be recreated as part of this migration, and the values
* will be enforced, causing the entire update chain to be triggered, and
* restoring correct is_present values for all AlbumTrack/Album/Artist entries
*/
void
MediaLibrary
::
migrateModel12to13
()
{
auto
t
=
getConn
()
->
newTransaction
();
const
std
::
string
req
=
"DROP TRIGGER IF EXISTS is_track_presentAFTER"
;
sqlite
::
Tools
::
executeDelete
(
getConn
(),
req
);
const
std
::
string
reqs
[]
=
{
"DROP TRIGGER IF EXISTS is_track_presentAFTER"
,
"DROP TRIGGER has_album_present"
,
"DROP TRIGGER is_album_present"
,
};
for
(
const
auto
&
req
:
reqs
)
sqlite
::
Tools
::
executeDelete
(
getConn
(),
req
);
AlbumTrack
::
createTriggers
(
getConn
()
);
Album
::
createTriggers
(
getConn
()
);
Artist
::
createTriggers
(
getConn
(),
13
);
// Leave the weak context as we now need to update is_present fields, which
// are propagated through recursive triggers
const
std
::
string
migrateData
=
"UPDATE "
+
policy
::
AlbumTrackTable
::
Name
+
...
...
test/unittest/MiscTests.cpp
View file @
30c7bf0c
...
...
@@ -171,6 +171,8 @@ TEST_F( DbModel, Upgrade12to13 )
ASSERT_EQ
(
InitializeResult
::
Success
,
res
);
// We can't check for the number of albums anymore since they are deleted
// as part of 13 -> 14 migration
CheckNbTriggers
(
31
);
}
TEST_F
(
DbModel
,
Upgrade13to14
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment