Skip to content

Commit ec78363

Browse files
committed
Allow annotations migration to work with both option and annotations tables
1 parent 8d3d652 commit ec78363

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

Migrations/AnnotationsMigration.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,32 @@
1515

1616
class AnnotationsMigration extends BaseMigration
1717
{
18+
/**
19+
* @param TargetDb $targetDb
20+
* @return array
21+
*/
1822
public function validateStructure(TargetDb $targetDb)
1923
{
20-
return array();
24+
// since Matomo 5.5.0, annotations are stored in their own table
25+
// and the AnnotationList class had been removed
26+
if (!class_exists(AnnotationList::class)) {
27+
return $this->checkTablesHaveSameStructure($targetDb, 'annotations');
28+
}
29+
30+
return [];
2131
}
2232

2333
public function migrate(Request $request, TargetDb $targetDb)
2434
{
35+
// since Matomo 5.5.0, annotations are stored in their own table
36+
// and the AnnotationList class had been removed
37+
if (!class_exists(AnnotationList::class)) {
38+
$this->migrateEntities($request, $targetDb, 'annotations', 'annotations', 'id');
39+
40+
return;
41+
}
42+
43+
// before Matomo 5.5.0, annotations were stored in the options table
2544
$sourceName = AnnotationList::getAnnotationCollectionOptionName($request->sourceIdSite);
2645
$targetName = AnnotationList::getAnnotationCollectionOptionName($request->targetIdSite);
2746

0 commit comments

Comments
 (0)