diff --git a/CHANGELOG.md b/CHANGELOG.md index faa75e2..1d67de9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## Changelog +### 5.0.4 - 2024-09-16 +- Added code to continue import if duplicate records are found in archive table + ### 5.0.3 - Added plugin category for Marketplace diff --git a/Migrations/ArchiveMigration.php b/Migrations/ArchiveMigration.php index 117b1fc..07c8d19 100644 --- a/Migrations/ArchiveMigration.php +++ b/Migrations/ArchiveMigration.php @@ -53,7 +53,19 @@ public function migrate(Request $request, TargetDb $targetDb) if (!empty($archive['idarchive'])) { $archive['idarchive'] = $this->createArchiveId($targetDb, $archiveTable, $archive['idarchive']); $archive['idsite'] = $request->targetIdSite; - $targetDb->insert($archiveTable, $archive); + try { + $targetDb->insert($archiveTable, $archive); + } catch (\Exception $e) { + if ( + $e->getCode() == 23000 + || strpos($e->getMessage(), 'Duplicate entry') !== false + || strpos($e->getMessage(), ' 1062 ') !== false + ) { + $this->log('Duplicate entry in ' . $archiveTable . ' table for archiveID: ' . $archive['idarchive'] . ' and name: ' . $archive['name']); + continue; + } + throw new \Exception($e->getMessage()); + } } } } diff --git a/plugin.json b/plugin.json index d74dc16..26ad54e 100644 --- a/plugin.json +++ b/plugin.json @@ -1,7 +1,7 @@ { "name": "Migration", "description": "Migrate/copy any measurable (site, app, roll-up) from one Matomo to another Matomo", - "version": "5.0.3", + "version": "5.0.4", "theme": false, "require": { "matomo": ">=5.0.0-b1,<6.0.0-b1"