Skip to content

Commit

Permalink
Merge pull request #70 from matomo-org/PG-3865-continue-on-duplicate
Browse files Browse the repository at this point in the history
Continue on duplicate entry, #PG-3865
  • Loading branch information
AltamashShaikh authored Sep 16, 2024
2 parents f2dbf76 + 9fd902b commit 5110417
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
14 changes: 13 additions & 1 deletion Migrations/ArchiveMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 5110417

Please sign in to comment.